Skip to content

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

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

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

Superseded by #224 (release/2.0). The decoder error contract and its regression tests are already included in release/2.0. Further release fixes are in the stack ending at #239. This PR is retained for historical context.


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
@leoafarias
leoafarias force-pushed the codex/ack-v2-codec-error-contract branch from b322401 to ac6f353 Compare October 9, 2026 14:04
@leoafarias leoafarias added the superseded Replaced by consolidated work in another pull request or release branch. label Oct 26, 2026
@leoafarias leoafarias closed this Oct 26, 2026
@leoafarias
leoafarias deleted the codex/ack-v2-codec-error-contract branch October 26, 2026 21:21
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 superseded Replaced by consolidated work in another pull request or release branch.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant