Skip to content

fix(core): type absent records as Error::NotFound (was InvalidData)#153

Open
Nic-dorman wants to merge 1 commit into
mainfrom
fix/typed-notfound-error
Open

fix(core): type absent records as Error::NotFound (was InvalidData)#153
Nic-dorman wants to merge 1 commit into
mainfrom
fix/typed-notfound-error

Conversation

@Nic-dorman

Copy link
Copy Markdown
Contributor

Problem

data::Error has no not-found variant, so a well-formed address with nothing stored at it surfaces as Error::InvalidData — an error class that means the caller sent something malformed. The absent-record signal already exists (chunk_get returns Ok(None)); it's the conversion sites that stringify it away:

  • data_map_fetch / data_map_fetch_from_closest_peersInvalidData("DataMap chunk not found at …")
  • data_download's reconstruction miss → InvalidData("Missing chunk … required for data reconstruction")

Downstream this misleads real users: ant-ffi maps InvalidDataInvalidInput, so the mobile SDKs show "invalid input" for a mistyped or absent address and can't offer "not found — check the address" UX. (Mobile tracker: V2-650; sibling of #152 — same lossy-stringification family.)

Change

  • New Error::NotFound(String) variant, documented against InvalidData (absent record vs retrieved-but-malformed/integrity-failing content).
  • The three definitively-absent conversion sites now return it (messages unchanged). The genuine integrity checks (mismatched chunk address / content hash in chunk.rs) correctly remain InvalidData.
  • classify_error: NotFoundOutcome::ApplicationError — the peers answered over a working link, so absence must not push the adaptive limiter down. (The Ok(None) → Timeout load-shedding signal inside chunk_get_observed is fed pre-conversion via chunk_get_outcome and is unaffected.)
  • Doc updates on the three public fns' # Errors sections.

Tests

  • classify_error_covers_all_variants + the compile-time exhaustiveness guard extended.
  • Display test for the new variant.
  • cargo fmt --check ✓ · cargo clippy --all-targets --all-features -- -D warnings ✓ · cargo test -p ant-core --lib 411 passed · cargo test -p ant-cli 18 passed.

Consumer

Once this ships in an ant-core release, ant-ffi adds a one-arm From mapping to its existing ClientError::NotFound and mobile apps can finally distinguish not-found from caller error.

🤖 Generated with Claude Code

A well-formed address with nothing stored at it previously surfaced as
Error::InvalidData ('DataMap chunk not found at …' / 'Missing chunk …
required for data reconstruction'), which reads as a caller bug.
Downstream SDKs inherit that: ant-ffi maps InvalidData to InvalidInput,
so mobile apps show 'invalid input' for a mistyped or absent address
and cannot offer 'not found — check the address' UX.

The not-found signal already existed as chunk_get's Ok(None); this
re-types the three definitively-absent conversion sites (data_map_fetch,
data_map_fetch_from_closest_peers, and the data_download reconstruction
miss) to a new Error::NotFound variant. Integrity failures (mismatched
address / content hash) correctly remain InvalidData.

classify_error treats NotFound as ApplicationError: the peers answered
over a working link, so it must not push the adaptive limiter down.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant