fix(core): type absent records as Error::NotFound (was InvalidData)#153
Open
Nic-dorman wants to merge 1 commit into
Open
fix(core): type absent records as Error::NotFound (was InvalidData)#153Nic-dorman wants to merge 1 commit into
Nic-dorman wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
data::Errorhas no not-found variant, so a well-formed address with nothing stored at it surfaces asError::InvalidData— an error class that means the caller sent something malformed. The absent-record signal already exists (chunk_getreturnsOk(None)); it's the conversion sites that stringify it away:data_map_fetch/data_map_fetch_from_closest_peers→InvalidData("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
InvalidData→InvalidInput, 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
Error::NotFound(String)variant, documented againstInvalidData(absent record vs retrieved-but-malformed/integrity-failing content).chunk.rs) correctly remainInvalidData.classify_error:NotFound→Outcome::ApplicationError— the peers answered over a working link, so absence must not push the adaptive limiter down. (TheOk(None)→ Timeout load-shedding signal insidechunk_get_observedis fed pre-conversion viachunk_get_outcomeand is unaffected.)# Errorssections.Tests
classify_error_covers_all_variants+ the compile-time exhaustiveness guard extended.cargo fmt --check✓ ·cargo clippy --all-targets --all-features -- -D warnings✓ ·cargo test -p ant-core --lib411 passed ·cargo test -p ant-cli18 passed.Consumer
Once this ships in an ant-core release, ant-ffi adds a one-arm From mapping to its existing
ClientError::NotFoundand mobile apps can finally distinguish not-found from caller error.🤖 Generated with Claude Code