Skip to content

feat(ack)!: unify decoder and encoder error contracts - #163

Draft
leoafarias wants to merge 1 commit into
mainfrom
codex/ack-v2-codec-error-contract
Draft

leoafarias wants to merge 1 commit into
mainfrom
codex/ack-v2-codec-error-contract

Conversation

@leoafarias

@leoafarias leoafarias commented Sep 27, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Unify decoder and encoder error contracts in CodecSchema:

  • Propagate programmer Errors: When a codec decoder or one-way .transform() callback throws a Dart Error (such as StateError or TypeError), rethrow it with its original stack trace (Error.throwWithStackTrace) instead of wrapping it in a SchemaTransformError, matching the existing encoder and refinement contracts.
  • Keep recoverable Exceptions as validation failures: Ordinary Exception values (such as FormatException) continue to return SchemaTransformError failures so union schemas (Ack.anyOf) can fall back to subsequent branches on invalid input without silently swallowing programmer defects.
  • Tests: Add public-interface regression tests covering parse/safeParse, nested Ack.object/Ack.list/Ack.map, one-way .transform(), Ack.anyOf short-circuiting, recoverable FormatException fallback, and stack trace preservation.

Breaking Change (Ack 2.0)

Decoder callbacks that threw a StateError or other Error subclass to signal invalid user input should throw FormatException (or another Exception) instead.

Stack (Ack 2.0)

@leoafarias leoafarias changed the title fix(ack): preserve codec decoder errors — 2.0 foundation feat(ack)!: unify decoder and encoder error contracts Sep 27, 2026
leoafarias added a commit that referenced this pull request Sep 29, 2026
Align the six publishable packages at 1.7.0-beta.1 and move unreleased
notes into the 1.7.0-beta.1 changelog sections. The release includes
shared inference, model adapter schemas, CodecSchema.canEncode, typed
copyWith, stricter constrained-Set validation, the @AckInfer schema
shorthand (#174), generated string-literal escaping (#164), and explicit
schema descriptions (#176). Update PUBLISHING.md for this candidate.

The Draft 2020-12 runtime (#171), JSON Schema-to-Dart generation (#167),
and the decoder error contract (#163) are deferred to 2.0.
@leoafarias leoafarias added the 2.0 Planned for Ack 2.0 label Oct 1, 2026

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

2.0 Planned for Ack 2.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant