Skip to content

Return decoding errors for invalid SATS type references - #5962

Open
pederbe wants to merge 1 commit into
clockworklabs:masterfrom
pederbe:learn/4001-invalid-type-reference
Open

pederbe wants to merge 1 commit into
clockworklabs:masterfrom
pederbe:learn/4001-invalid-type-reference

Conversation

@pederbe

@pederbe pederbe commented Sep 21, 2026

Copy link
Copy Markdown

Description of Changes

Fixes #4001.

Decoding an AlgebraicType::Ref with no matching type currently panics while indexing the typespace. Use checked lookups when decoding or validating values and array elements, returning the existing custom decoding error for an out-of-bounds reference.

Reference resolution remains lazy, preserving valid aliases, finite recursive values, and unselected sum branches.

API and ABI breaking changes

None. Encountered out-of-bounds references now return an error instead of panicking. No public signatures, error variants, or wire formats change.

Rollback safety impact

n/a

Expected complexity level and risk

  1. The change is limited to reference lookup in the SATS decoder and reuses the existing lookup and error conventions.

Testing

  • Reproduced the reported panic before the fix; the regression passes afterward.
  • Added decoding and validation coverage for invalid references, array elements, aliases, and finite recursive values.
  • SATS tests with default and all features, Clippy with warnings denied, formatting, and documentation checks passed on Rust 1.93.0 under Linux. Existing ignored tests remain ignored. Full workspace and SDK suites were not run.

@pederbe
pederbe marked this pull request as ready for review September 21, 2026 11:12

This branch has not been deployed

No deployments
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.

Panic in BSATN Deserializer via Invalid Type Reference

2 participants