Guard against contributors failing to load correctly #229

Merged
raucao merged 2 commits from bugfix/missing-contributor-crash into master 2026-07-26 11:24:46 +00:00
Owner

I don't know how I ended up there, but it seems like I had a bad contributor profile stored in my IndexedDB. In order for others not also having to manually delete the database for the app to work again, let's just guard against the situation.

Problem

A contributor whose IPFS profile has no accounts array causes @kredits/contracts' ContributorSerializer.deserialize to throw → Contributor.getById rejects → the contributor never enters this.contributorsloadContributionFromData attaches contributor: undefinedUserAvatar throws Cannot read properties of undefined (reading 'github_uid') on render → the run-loop breaks and fetchMissingContributions / subsequent contribution loading stalls, so no further contributions are loaded.

Fix (app-side)

  • app/components/user-avatar/component.js: guard against this.contributor being undefined; added contributor to the computed's dependent keys so avatars re-render when a contributor is lazily loaded later.
  • app/services/kredits.jskreditsByContributor: filter out groups whose contributor isn't loaded instead of dereferencing undefined.totalKreditsEarned.
  • app/services/kredits.js — new ensureContributorLoaded(id): called from loadContributionFromData and loadReimbursementFromData; fire-and-forget background fetch of the missing contributor, deduped via a contributorsFetching Set (added in init) so a tight loop over many contributions for the same missing contributor doesn't hammer the RPC. Rejections are logged, never thrown, so the run loop can't be broken by a persistently broken profile. On success, dependent computeds (kreditsByContributor, UserAvatar) retrigger via contributors.[].

Tests

  • tests/integration/components/user-avatar/component-test.js: undefined contributor; contributor without github_uid.
  • tests/unit/services/kredits-test.js: #kreditsByContributor with an orphan contribution referencing a non-existent contributor id (asserts no throw and no orphan entry in the toplist).

refs #224

I don't know how I ended up there, but it seems like I had a bad contributor profile stored in my IndexedDB. In order for others not also having to manually delete the database for the app to work again, let's just guard against the situation. ### Problem A contributor whose IPFS profile has no `accounts` array causes `@kredits/contracts`' `ContributorSerializer.deserialize` to throw → `Contributor.getById` rejects → the contributor never enters `this.contributors` → `loadContributionFromData` attaches `contributor: undefined` → `UserAvatar` throws `Cannot read properties of undefined (reading 'github_uid')` on render → the run-loop breaks and `fetchMissingContributions` / subsequent contribution loading stalls, so no further contributions are loaded. ### Fix (app-side) - **`app/components/user-avatar/component.js`**: guard against `this.contributor` being undefined; added `contributor` to the computed's dependent keys so avatars re-render when a contributor is lazily loaded later. - **`app/services/kredits.js` — `kreditsByContributor`**: filter out groups whose contributor isn't loaded instead of dereferencing `undefined.totalKreditsEarned`. - **`app/services/kredits.js` — new `ensureContributorLoaded(id)`**: called from `loadContributionFromData` and `loadReimbursementFromData`; fire-and-forget background fetch of the missing contributor, deduped via a `contributorsFetching` Set (added in `init`) so a tight loop over many contributions for the same missing contributor doesn't hammer the RPC. Rejections are logged, never thrown, so the run loop can't be broken by a persistently broken profile. On success, dependent computeds (`kreditsByContributor`, `UserAvatar`) retrigger via `contributors.[]`. ### Tests - `tests/integration/components/user-avatar/component-test.js`: undefined contributor; contributor without `github_uid`. - `tests/unit/services/kredits-test.js`: `#kreditsByContributor` with an orphan contribution referencing a non-existent contributor id (asserts no throw and no orphan entry in the toplist). refs #224
raucao added 1 commit 2026-07-25 17:35:16 +00:00
raucao added 1 commit 2026-07-25 18:19:20 +00:00
Merge branch 'master' into bugfix/missing-contributor-crash
CI / Lint (pull_request) Successful in 1m6s
CI / Test (pull_request) Successful in 1m58s
Release Drafter / Update release notes draft (pull_request) Successful in 3s
51a9c8ad6f
raucao added the enhancement label 2026-07-26 11:22:09 +00:00
raucao added the kredits-1 label 2026-07-26 11:24:06 +00:00
raucao changed title from Guard dashboard against contributors that fail to load from IPFS to Guard dashboard against contributors failing to load correctly 2026-07-26 11:24:35 +00:00
raucao changed title from Guard dashboard against contributors failing to load correctly to Guard against contributors failing to load correctly 2026-07-26 11:24:40 +00:00
raucao merged commit 9054821e52 into master 2026-07-26 11:24:46 +00:00
raucao deleted branch bugfix/missing-contributor-crash 2026-07-26 11:24:46 +00:00
Sign in to join this conversation.