Skip to content

fix(github): fetchPublicContributorProfile discards already-fetched user data on a JSON-parse failure, but not on an HTTP failure #8891

Description

@JSONbored

⚠️ Definition of Done: this issue must be completed in full, in a single PR. Do not split this
work across multiple PRs, and do not defer any Deliverable below to a follow-up issue. A PR that
satisfies only some of the Deliverables, stubs a required test, or leaves a checkbox
partially-done does NOT resolve this issue and will be closed.

Context

src/github/public.ts:83-133: if reposResponse.ok is false, the function degrades gracefully (repos = [], user.login/name/bio/... still returned, source: "github"). But if reposResponse.ok is true and the body fails to parse (await reposResponse.json() throws -- e.g. a truncated stream), the outer catch at line 127 discards the whole result, including the already-successfully-parsed user object, returning { login, topLanguages: [], source: "unavailable" }. test/unit/adapters.test.ts only covers the HTTP-level non-ok case (line 159), never a parse failure after a successful user fetch.

Requirements

Catch the repos-list fetch/parse separately from the user fetch, so a repos-side failure (HTTP or parse) degrades to topLanguages: [] while preserving already-fetched user fields, instead of collapsing the whole profile to unavailable.

Deliverables

  • A repos-list JSON-parse failure preserves already-fetched user fields, degrading only topLanguages to [], matching the existing HTTP-failure degrade behavior
  • A test in test/unit/adapters.test.ts asserting a parse failure after a successful user fetch still returns the real user fields, not source: "unavailable"

All of the above Deliverables are required in the same PR unless the deliverable text itself states otherwise.

Test Coverage Requirements

src/** -- 99%+ patch coverage, branch-counted, on the new separated catch path.

Expected Outcome

A repos-list parse failure degrades the same way an HTTP-level failure already does -- preserving the successfully-fetched user profile instead of discarding it.

Links & Resources

  • src/github/public.ts:83-133
  • test/unit/adapters.test.ts:159

Metadata

Metadata

Assignees

No one assigned

    Labels

    gittensor:bugGittensor-scored bug fix — scores a 0.05x multiplier.help wantedExtra attention is needed

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions