Skip to content

fix(miner): retry transient 5xx/rate-limit in contribution-profile getJson#7126

Merged
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
bitfathers94:fix/issue-7090
Jul 17, 2026
Merged

fix(miner): retry transient 5xx/rate-limit in contribution-profile getJson#7126
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
bitfathers94:fix/issue-7090

Conversation

@bitfathers94

Copy link
Copy Markdown
Contributor

What & why

extractContributionProfile's getJson
(packages/loopover-miner/lib/contribution-profile-extract.js) fetched a repo's label taxonomy and
CONTRIBUTING.md by calling fetchImpl directly with no retry, unlike its sibling
opportunity-fanout.js's githubGetJson, which already wraps the identical class of request in
fetchWithRetry. A single transient GitHub 5xx or rate-limit response (429 / secondary-403) therefore
degraded the label/doc signal to absent/unknown on the first blip.

That matters more than a typical missing-retry gap: discover-cli.js's
resolveContributionProfilesForDiscover immediately cache.put()s whatever extract() returns into the
persistent contribution-profile cache, keyed by repo with its own TTL. So one transient 5xx during a
discover run got cached as the repo's eligibility signal and kept silently weakening label-based
filtering until the entry expired — even though the repo's real label taxonomy was reachable moments
before or after the blip.

Change

  • getJson now routes through fetchWithRetry (./http-retry.js) — same retryable-status semantics,
    bounded attempts, and exponential-backoff-or-Retry-After delay as githubGetJson.
  • The per-attempt request timeout is preserved via fetchWithRetry's timeoutMs option (a fresh
    AbortSignal.timeout per attempt) — a straight pass-through, not a redesign.
  • The documented never-throws / fail-open contract is unchanged: a plain 4xx, a thrown transport
    error, an unparseable body, or genuinely-exhausted retries all still return null.
  • A sleepFn seam is threaded from extractContributionProfile's options through getJson /
    fetchContributing, mirroring every other fetchWithRetry call site, so the retry is testable with no
    real timers.

Tests

Added to test/unit/contribution-profile-extract.test.ts (injected sleepFn, no real timers):

  • labels fetch returns a transient 5xx on the first attempt then succeeds → same explicit-eligibility
    profile as an immediate success (not a degraded absent).
  • CONTRIBUTING.md fetch returns a transient 5xx then succeeds → linked-issue rule read as explicit,
    as if it never blipped.
  • labels fetch fails on every attempt → still degrades to absent, exactly DEFAULT_MAX_ATTEMPTS
    attempts with 2 sleeps between them, never throws.
  • doc fetch fails on every attempt → prBody still absent, fail-open contract preserved.

100% Codecov patch coverage on every changed line and branch in contribution-profile-extract.js
(measured unsharded); the file's only non-covered branch is the pre-existing githubHeaders
no-token arm, outside this diff.

Closes #7090

…tJson

extractContributionProfile's getJson fetched a repo's label taxonomy and
CONTRIBUTING.md by calling fetchImpl directly with no retry, so a single
transient GitHub 5xx or rate-limit response (429 / secondary-403) degraded
the signal to absent/unknown. Because discover-cli persists whatever extract()
returns into the contribution-profile cache, that one blip got cached as the
repo's eligibility signal until the entry expired, silently weakening label
filtering for a repo that was reachable moments before or after.

Route getJson through fetchWithRetry (./http-retry.js) — the same helper
opportunity-fanout.js's sibling githubGetJson already uses — so a retryable
status rides out its bounded attempts with exponential-backoff-or-Retry-After
delay before falling back. The per-attempt REQUEST_TIMEOUT_MS is preserved via
fetchWithRetry's timeoutMs (a fresh AbortSignal.timeout per attempt), the
never-throws / fail-open contract is unchanged once retries are exhausted, and
a sleepFn seam is threaded through so the retry is testable without real timers.

Closes JSONbored#7090
@bitfathers94
bitfathers94 requested a review from JSONbored as a code owner July 17, 2026 22:26
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@codecov

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.98%. Comparing base (814a3f0) to head (33300cd).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7126   +/-   ##
=======================================
  Coverage   95.98%   95.98%           
=======================================
  Files         609      609           
  Lines       48153    48154    +1     
  Branches    15133    15133           
=======================================
+ Hits        46218    46219    +1     
  Misses       1118     1118           
  Partials      817      817           
Flag Coverage Δ
shard-1 43.38% <0.00%> (-0.41%) ⬇️
shard-2 36.86% <0.00%> (+0.01%) ⬆️
shard-3 33.17% <100.00%> (+0.03%) ⬆️
shard-4 34.39% <0.00%> (-0.09%) ⬇️
shard-5 31.74% <0.00%> (-0.55%) ⬇️
shard-6 46.12% <100.00%> (+0.27%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...loopover-miner/lib/contribution-profile-extract.js 100.00% <100.00%> (ø)

@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 17, 2026
@loopover-orb

loopover-orb Bot commented Jul 17, 2026

Copy link
Copy Markdown

Tip

✅ LoopOver review result - approve/merge recommended

Review updated: 2026-07-17 22:41:04 UTC

3 files · 1 AI reviewer · no blockers · readiness 98/100 · CI green · clean

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This PR wires contribution-profile-extract.js's getJson through the existing fetchWithRetry helper (already used by opportunity-fanout.js's githubGetJson), fixing a real bug where a single transient 5xx/429 during discover got permanently cached as a degraded eligibility signal. The change is a straight pass-through of the existing retry contract (bounded attempts, backoff, per-attempt AbortSignal.timeout via timeoutMs) and preserves the never-throws/fail-open contract on genuine exhaustion or 4xx. Tests are thorough and non-fabricated: they exercise a single-blip-then-success path, an exhausted-retries-still-fails-open path, and correctly assert the doubled attempt count (3 attempts × 2 CONTRIBUTING.md probe paths = 6) that falls naturally out of retrying each path independently.

Nits — 4 non-blocking
  • contribution-profile-extract.js:fetchContributing retries each of the two CONTRIBUTING.md probe paths to full exhaustion independently, so a persistently-down GitHub now costs up to 6 attempts (3×2) instead of 2 before falling back — worth a one-line comment noting this is accepted latency, not a bug.
  • The JSDoc on getJson (contribution-profile-extract.js:78-83) is quite long for a single function; consider trimming to the non-obvious parts (retry delegation + fail-open contract) since the mechanics are already documented in http-retry.js.
  • Confirm fetchWithRetry's signature/behavior (not shown in this diff) truly matches what opportunity-fanout.js's githubGetJson relies on, since the retry semantics here are asserted by reference rather than visible in the diff.
  • Consider whether the two CONTRIBUTING.md probe paths should share a single retry budget instead of each getting a full independent retry allotment, to bound worst-case latency during a sustained outage.

Decision drivers

  • ✅ Code review — No blockers (1 reviewer)
  • ✅ Gate result — Passing (No configured blocker found.)
Context & advisory signals — never blocks the verdict
Signal Result Evidence
Linked issue ✅ Linked #7090
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (1 linked issue).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 0 registered-repo PR(s), 0 merged, 0 issue(s).
Contributor context ℹ️ No public Gittensor match bitfathers94; not a blocker.
Improvement ✅ Minor risk: clean · value: minor · LLM: moderate
Review context
  • Author: bitfathers94
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: not available
  • Contributor context: Public profile only; not a blocker.
  • PR-specific overlap: none found.
Contributor next steps
  • Keep the PR focused and include validation evidence before maintainer review.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
🧪 Chat with LoopOver

Ask LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.

  • @loopover ask &lt;question&gt; answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat &lt;question&gt; answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @loopover mention with a real question is routed to the closest matching read-only command automatically — no exact syntax required.

Full command reference: https://loopover.ai/docs/loopover-commands

🧪 Experimental — new and may change.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.

  • Re-run LoopOver review

@loopover-orb loopover-orb Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LoopOver approves — the gate is satisfied and CI is green.

@loopover-orb
loopover-orb Bot merged commit ec15d24 into JSONbored:main Jul 17, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

contribution-profile-extract.js's getJson has no retry-on-5xx, unlike opportunity-fanout.js's sibling fetcher, and its degraded result gets cached

1 participant