Repository navigation
fix(schema): give predicate errors an explicit expected default - #1668
Merged
Merged
Conversation
ctx.reject without `expected` creates a predicate error with no `predicate` in its context. Union error aggregation reads `expected` from each branch, which fell back to the default description and dereferenced `predicate.name`, throwing a TypeError. Fixes #1667 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — verified the one-line crash fix and the accompanying regression test.
- Missing-predicate guard:
node.predicate?.name || "an anonymous predicate"in the predicatedescriptiondefault (ark/schema/predicate.ts:68) now tolerates the error-context form thatimplementNodepasses here, resolving theTypeErrorfrom #1667. - Regression test:
narrow.test.ts:258pins the non-discriminated-union message. I revertedpredicate.tsto the base and confirmed it reproducesTypeError: Cannot read properties of undefined (reading 'name'), then passes with the fix.
Full suite (pnpm test) passes at 1752 tests; eslint and prettier --check are clean on both files. The fallback message drops a custom ctx.reject({ problem }) in favor of the generic predicate description — that is the pre-existing union expected-aggregation behavior, and the snapshot intentionally records it.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
The generic expected default in implementNode falls back to calling the node's description writer with the error context. That only works when the context mirrors the node's inner, but predicate error contexts never carry `predicate` (it is optional in Predicate.ErrorContext and nothing sets it), and those from ctx.reject have no `description` either. Rather than making the node's description tolerate a missing predicate, predicate now defines `expected` over its actual error context, so the node-typed description stays sound. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
ssalbdivad
added a commit
that referenced
this pull request
Sep 30, 2026
Bumps all publishable packages and documents the changes merged since 2.2.5: - add ArkErrors.message, aliasing summary (#1671) - fix a TypeError when ctx.reject without `expected` fails in an undiscriminated union (#1668, fixes #1667) - preserve narrows on piped union branches through an intersection (#1658, fixes #1608, @ShuviSchwarze) - format times in Date descriptions independent of the default locale (#1603, fixes #1494, @WolfieLeader) #1603 changes the text of Date error messages in 24-hour locales, e.g. "14:30, January 15, 2023" is now "2:30 PM, January 15, 2023". Co-authored-by: Claude Opus 5.5 (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.

Fixes #1667