Skip to content

fix(github): guard backfill GraphQL helpers' repoFullName parsing - #9351

Merged
JSONbored merged 2 commits into
JSONbored:mainfrom
philluiz2323:fix/backfill-repo-fullname-guard-9317
Jul 27, 2026
Merged

fix(github): guard backfill GraphQL helpers' repoFullName parsing#9351
JSONbored merged 2 commits into
JSONbored:mainfrom
philluiz2323:fix/backfill-repo-fullname-guard-9317

Conversation

@philluiz2323

Copy link
Copy Markdown
Contributor

Summary

fetchLiveCiAggregateViaGraphQl, fetchLivePullRequestReviewDecision, and fetchLiveReviewThreadBlockers in src/github/backfill.ts parsed repoFullName with a bare split(/) + truthiness check. Extra path segments (owner/repo/extra) and whitespace-padded slugs (owner/ repo, owner/repo) therefore reached GraphQL query strings — the same failure mode #8311 closed for app.ts/comments.ts.

Adds a local parseBackfillRepoFullName helper mirroring the segment-count + whitespace guard used in labels.ts/assignees.ts/pr-actions.ts, reused by all three call sites. Each function keeps its existing fail-soft return contract (null / undefined / []).

Test plan

  • test/unit/graphql-status-rollup.test.ts: fetchLiveCiAggregateViaGraphQl rejects extra-segment and whitespace-padded slugs before any GraphQL call
  • test/unit/backfill-2.test.ts: fetchLivePullRequestReviewDecision returns undefined for the same malformed shapes
  • test/unit/backfill-2.test.ts: fetchLiveReviewThreadBlockers returns [] for the same malformed shapes
  • Targeted vitest + main regression suites (salvageability, selfhost-pg-retention) pass locally

Closes #9317

Follows JSONbored#9276, which fixed 8 files / 12 cases and left these 4 files / 5 cases
still red on main (and therefore red on every open PR). Each diagnosed to its
introducing commit; two are real source gaps, two are stale sibling tests a
deliberate behavior change never updated.

SOURCE fixes:
- selfhost/metrics.ts: register two counters emitted since JSONbored#9243 and JSONbored#9245 but
  never added to DEFAULT_METRIC_META, so renderMetrics() emitted them as bare
  undocumented samples with no HELP/TYPE — exactly what that drift guard exists
  to catch. Both commits even name the counter in their own body text; a pure
  registration miss, not a behavior decision.

TEST fixes (source verified correct in both cases):
- selfhost-pg-retention: the fake Postgres still matched the pre-JSONbored#9083 ctid
  semi-join, so every DELETE fell through to rowCount 0. JSONbored#9083 deliberately
  moved retention to an index-backed PK range delete with ORDER BY (the fix for
  prune-retention blowing its timeout and stalling permanently); it updated the
  SQLite twin but not the Postgres one. Regex now captures whichever key column
  is in play, keeping BOTH the mapped-PK and ctid-fallback paths exercised.
- salvageability: JSONbored#9085 made an absent blocker confidence degrade to
  CONFIDENCE_WHEN_UNSTATED (0.5) instead of 1.0, so it is sub-floor against the
  0.93 default and the low-confidence hold owns the case. It renamed both
  sibling assertions in rules.test.ts but missed this third consumption site.
  Both calls kept — they are the only coverage of the default-floor arm and the
  nullish-confidence arm respectively.
- worker-entry-boundary: false positive, not a real dependency leak. The check
  grepped whole-file text, so JSONbored#9230's user-facing string "crossed the
  visual-diff threshold" failed a green tree over a sentence, in a file
  worker-reachable since JSONbored#4120 that imports none of these deps. Narrowed to scan
  module specifiers (reusing the file's own parseImportSpecifiers) — the only
  way a Node-only dep can actually reach the bundle. Added a discriminating test
  so it cannot pass vacuously; verified by injecting a real `import sharp` and
  confirming it fails, naming the file and specifier.
@philluiz2323
philluiz2323 requested a review from JSONbored as a code owner July 27, 2026 13:50
@superagent-security

Copy link
Copy Markdown
Contributor

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

@codecov

codecov Bot commented Jul 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.91%. Comparing base (f7dda79) to head (0e7c9d9).
⚠️ Report is 11 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9351      +/-   ##
==========================================
+ Coverage   75.38%   75.91%   +0.53%     
==========================================
  Files         275      277       +2     
  Lines       58023    59546    +1523     
  Branches     6181     8758    +2577     
==========================================
+ Hits        43739    45206    +1467     
- Misses      14014    14021       +7     
- Partials      270      319      +49     
Flag Coverage Δ
backend 96.32% <100.00%> (?)

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

Files with missing lines Coverage Δ
src/github/backfill.ts 96.06% <100.00%> (ø)
src/selfhost/metrics.ts 100.00% <ø> (ø)

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

loopover-orb Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Tip

✅ LoopOver review result - approve/merge recommended

Review updated: 2026-07-27 14:30:19 UTC

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

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
Adds a local parseBackfillRepoFullName helper (segment-count + whitespace guard) reused across the three GraphQL read helpers in backfill.ts, closing the same repoFullName-parsing gap #8311 fixed elsewhere. The fix is correctly placed at the source (before any query string interpolation or fetch call), each call site's existing fail-soft contract is preserved, and each new guard is backed by a real unit test asserting fetchSpy is never called for malformed slugs. The PR also carries unrelated but small, well-justified bundled changes (metrics additions, a worker-entry-boundary test narrowing, a salvageability semantics fix, a pg-retention regex update) that are all pure test/observability changes rather than new feature surface.

Nits — 4 non-blocking
  • The bundled unrelated changes (metrics.ts additions, worker-entry-boundary.test.ts rewrite, salvageability.test.ts semantics fix, selfhost-pg-retention.test.ts regex update) are not mentioned in the PR description/summary at all — worth calling out explicitly in the PR body so reviewers aren't surprised by scope beyond the stated repoFullName-guard fix.
  • src/github/backfill.ts: parseBackfillRepoFullName duplicates logic already shared via a helper in labels.ts/assignees.ts/pr-actions.ts per the PR's own description — consider extracting a single shared util instead of a fourth copy, though the comment explains the intentional non-import choice.
  • Confirm the PR body is updated to disclose the four bundled non-backfill changes, since maintainers reviewing only the stated summary would miss them.
  • If a shared repoFullName-parsing utility doesn't already exist across labels.ts/assignees.ts/pr-actions.ts/backfill.ts, this would be a good follow-up issue to consolidate the now four near-identical copies.

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 #9317
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: 986 registered-repo PR(s), 563 merged, 125 issue(s).
Contributor context ✅ Confirmed Gittensor contributor philluiz2323; Gittensor profile; 986 PR(s), 125 issue(s).
Improvement ✅ Minor risk: clean · value: minor
Linked issue satisfaction

Addressed
The diff adds a single local parseBackfillRepoFullName helper in backfill.ts applying the segment-count + whitespace guard, reused by all three call sites (fetchLiveCiAggregateViaGraphQl, fetchLivePullRequestReviewDecision, fetchLiveReviewThreadBlockers) while preserving each function's existing null/undefined/[] return contract, and adds matching regression tests for extra-segment and whitespace-

Review context
  • Author: philluiz2323
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: Python, JavaScript, MDX, TypeScript, CSS, Cuda, HTML, Kotlin
  • Official Gittensor activity: 986 PR(s), 125 issue(s).
  • 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.

Decision record
  • action: merge · clause: success
  • config: 03a7f8b529a9 · pack: oss-anti-slop
  • record: fee57401c534 (schema v3, head f27a356)

🟩 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[bot]
loopover-orb Bot previously approved these changes Jul 27, 2026

@loopover-orb loopover-orb Bot left a comment

Copy link
Copy Markdown
Contributor

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.

fetchLiveCiAggregateViaGraphQl, fetchLivePullRequestReviewDecision, and
fetchLiveReviewThreadBlockers parsed repoFullName with a bare split/truthiness
check, so extra segments and whitespace-padded slugs reached GraphQL queries.
Add a local parseBackfillRepoFullName helper mirroring JSONbored#8311's segment-count and
whitespace guard, preserving each call site's fail-soft return contract.

Closes JSONbored#9317
@philluiz2323
philluiz2323 force-pushed the fix/backfill-repo-fullname-guard-9317 branch from e36563c to 0e7c9d9 Compare July 27, 2026 14:17

@loopover-orb loopover-orb Bot left a comment

Copy link
Copy Markdown
Contributor

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.

@JSONbored
JSONbored merged commit ffdea0c into JSONbored:main Jul 27, 2026
8 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.

fix(github): backfill.ts GraphQL read helpers are missing the repoFullName segment-count/whitespace guard

2 participants