Skip to content

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

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

queryDiscoveryIndex in packages/loopover-miner/lib/discovery-index-client.ts (~line 108) has a
bare catch block:

} catch {
  return EMPTY_QUERY_RESPONSE;
}

Any fetch/network/parse failure is silently dropped with zero logging, even at --verbose.

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

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

queryDiscoveryIndex's own doc comment area references mirroring orb-export.js's
sendAmsExportBatch convention — but that function actually surfaces the error in its return
value, and queryDiscoveryIndex's EMPTY_QUERY_RESPONSE return type has no slot for one, so a
debug log (matching submitSoftClaim's approach) is the correct fix, not a return-shape change.

Requirements

  • queryDiscoveryIndex's catch block must log the failure via getLogger().debug(...) before
    returning EMPTY_QUERY_RESPONSE, using the same describeCliError(error) shape
    submitSoftClaim already uses, with a distinct event name for this function (e.g.
    "discovery_plane_query_failed", mirroring submitSoftClaim's
    "discovery_plane_soft_claim_failed" naming convention).
  • Change catch { ... } to catch (error) { ... } so the error value is available to log.
  • Do not change queryDiscoveryIndex's return type or its fail-open behavior (still returns
    EMPTY_QUERY_RESPONSE on any failure) — only add the log line.
  • Do not change submitSoftClaim — it is already correct and is the precedent.

Deliverables

  • queryDiscoveryIndex's catch block logs the failure via getLogger().debug(...) with
    describeCliError(error), matching submitSoftClaim's pattern, before returning
    EMPTY_QUERY_RESPONSE.
  • A new test asserting that when the underlying fetch throws, queryDiscoveryIndex still
    returns EMPTY_QUERY_RESPONSE (unchanged fail-open behavior) AND the logger's debug method
    was called with the expected event name (mock/spy on the logger, mirroring however the
    existing submitSoftClaim test verifies its own log call, if one exists — if no such test
    exists yet for submitSoftClaim, write this test using a direct spy on getLogger()).

Both deliverables are required in this single PR.

Test Coverage Requirements

This repo enforces 99%+ Codecov patch coverage, branch-counted, on all changed lines/branches
(applies to packages/loopover-miner/lib/**). The new log line and its test must be covered.

Expected Outcome

A queryDiscoveryIndex failure (network error, non-OK response is already handled separately,
this is specifically the throw path) now leaves a debug-level log trace, matching the visibility
submitSoftClaim already provides for its own best-effort network call, instead of failing
completely silently even at --verbose.

Links & Resources

  • packages/loopover-miner/lib/discovery-index-client.ts (queryDiscoveryIndex ~line 108;
    submitSoftClaim ~lines 121-153, the precedent to mirror)

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