Skip to content

AuthoringMetaV2::fetch_for_contract panic-indexes metas[0] and decoded[0], relying on other crates' non-empty guarantees #211

Description

@thedavidmeister

Unit

crates/cli/src/meta/types/authoring/v2.rsAuthoringMetaV2::fetch_for_contract (AMT group g3-graphql-query-processing).

Intent oracle

fetch_for_contract returns Result<_, FetchAuthoringMetaV2WordError>; every failure mode in the pipeline is expressed as a wrapped error variant, so callers reasonably assume the function does not panic on remote data.

Violated property

Two unchecked indexings rely on non-emptiness guarantees that live elsewhere:

RainMetaDocumentV1Item::cbor_decode(metas[0].as_slice()).map_err(...)?[0].clone()
  • metas[0] is panic-free only because MetaboardSubgraphClient::get_metabytes_by_hash (a different crate, rain-metaboard-subgraph) returns Err(Empty) for an empty result set.
  • ...?[0] is panic-free only because cbor_decode rejects zero-item decodes with CorruptMeta.

Both are true today (verified by reading both call targets), so this is a latent hazard, not a current panic: any future relaxation of either invariant — or a new caller path — turns a remote-data condition into an index-out-of-bounds panic instead of a FetchAuthoringMetaV2WordError.

Verified repro

None reachable through the current dependency behaviour; this is a fragility finding backed by the cross-crate invariant trace above, flagged from the AMT survey note that marked these indexings for adversarial attention.

Triage framing

metas.first() / .get(0) with an explicit error (or documenting the invariants at the call site) would make panic-freedom local. Possibly acceptable as-is; flagging so the reliance is a recorded decision. Not adjudicating here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    adversarialFound by adversarial review/mutation testingauditAudit finding; counted by the org health scan

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions