Skip to content

fix(miner): log discovery-index query failures before failing open - #9346

Merged
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
jeffrey701:fix-9329-discovery-query-log
Jul 27, 2026
Merged

fix(miner): log discovery-index query failures before failing open#9346
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
jeffrey701:fix-9329-discovery-query-log

Conversation

@jeffrey701

Copy link
Copy Markdown
Contributor

What

queryDiscoveryIndex in packages/loopover-miner/lib/discovery-index-client.ts had a bare
} catch { return EMPTY_QUERY_RESPONSE; } — any fetch/network/parse failure was silently dropped
with zero logging, even at --verbose.

Its sibling submitSoftClaim in the same file — the equivalent best-effort fire-and-forget network
call — already logs the failure before returning its fail-open result:

} catch (error) {
  getLogger().debug("discovery_plane_soft_claim_failed", { error: describeCliError(error) });
  return { sent: false };
}

Change

Give queryDiscoveryIndex's catch the same treatment: bind the error (catch (error)) and
getLogger().debug("discovery_plane_query_failed", { error: describeCliError(error) }) before
returning. The fail-open behavior and the EMPTY_QUERY_RESPONSE return type are unchanged — this only
adds visibility. submitSoftClaim is untouched (it is the precedent). The event name mirrors its
discovery_plane_soft_claim_failed convention.

Validation

  • New test in test/unit/miner-discovery-index-client.test.ts: when the injected fetchImpl throws,
    queryDiscoveryIndex still returns empty (candidates: []) and logSpy.debug is called with
    "discovery_plane_query_failed" and { error: "network exploded" } (describeCliError returns the
    Error's message).
  • npx vitest run test/unit/miner-discovery-index-client.test.ts → 25 pass. The added lines are
    unconditional (no new branch) and are executed by the throw-path test.

Closes #9329

@jeffrey701
jeffrey701 requested a review from JSONbored as a code owner July 27, 2026 13:33
@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.40%. Comparing base (aad3f93) to head (70ade69).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9346      +/-   ##
==========================================
+ Coverage   75.38%   75.40%   +0.02%     
==========================================
  Files         275      276       +1     
  Lines       58023    58071      +48     
  Branches     6181     6204      +23     
==========================================
+ Hits        43739    43787      +48     
  Misses      14014    14014              
  Partials      270      270              
Flag Coverage Δ
backend 100.00% <100.00%> (?)

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

Files with missing lines Coverage Δ
...kages/loopover-miner/lib/discovery-index-client.ts 100.00% <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 13:42:45 UTC

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

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This is a minimal, well-scoped fix mirroring submitSoftClaim's existing error-logging pattern exactly: it binds the caught error and logs it via getLogger().debug with the same describeCliError shape before returning EMPTY_QUERY_RESPONSE. The fail-open behavior and return type are unchanged, only visibility is added, and the new test exercises the real throw-path (fetchImpl throws) rather than a fabricated scenario, verifying both the empty return and the logSpy call. Closes the linked issue #9329 and is narrowly targeted with no scope creep.

Nits — 2 non-blocking
  • The inline comment at discovery-index-client.ts:110-111 restates what the code/PR description already says (matching submitSoftClaim's convention) rather than explaining a non-obvious constraint — could be trimmed to a single short line.
  • Consider asserting `logSpy.debug` was called exactly once in the new test to guard against future double-logging regressions in this catch block.

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 #9329
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: 83 registered-repo PR(s), 38 merged, 17 issue(s).
Contributor context ✅ Confirmed Gittensor contributor jeffrey701; Gittensor profile; 83 PR(s), 17 issue(s).
Improvement ✅ Minor risk: clean · value: minor · LLM: minor
Linked issue satisfaction

Addressed
The catch block now binds the error and logs it via getLogger().debug("discovery_plane_query_failed", { error: describeCliError(error) }) before returning EMPTY_QUERY_RESPONSE, exactly mirroring submitSoftClaim's pattern, and a new test verifies both the fail-open return value and the logger call on the throw path.

Review context
  • Author: jeffrey701
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: Rust, TypeScript, Clojure, JavaScript
  • Official Gittensor activity: 83 PR(s), 17 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.

🟩 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
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.

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.

ams: queryDiscoveryIndex swallows fetch failures with no log, unlike its own sibling submitSoftClaim

1 participant