Repository navigation
fix(validators): Keep the field description of single-member allOf fields - #142
Merged
Merged
Conversation
…elds
Hey API merges the member of a single-member allOf over its wrapper, so a
field such as `{ allOf: [X], description, nullable }` showed X's own
description instead of its own, such as the dashboard `permissions` field.
Inline such members in normalize-spec when the wrapper only adds
annotations, so the wrapper's annotations win.
Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
sentry-junior
Bot
requested review from
BYK,
MathurAditya724 and
betegon
as code owners
November 9, 2026 21:24
BYK
approved these changes
Nov 9, 2026
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 9fa9fad. Configure here.
| Object.assign(node, allOf[0], annotations); | ||
| } | ||
| Object.values(node).forEach(inlineAnnotatedAllOf); | ||
| } |
There was a problem hiding this comment.
Nested allOf wrappers are not flattened
Low Severity
inlineAnnotatedAllOf inlines the current node before walking children, so a nested single-member allOf copied from the member stays on the wrapper. Hey API then merges that leftover member over the wrapper and the inner description replaces the field's.
Reviewed by Cursor Bugbot for commit 9fa9fad. Configure here.
2 tasks done
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.


Follow-up to #141. A field that wraps one schema in
allOf, such as{ allOf: [X], description, nullable }, showed X's own description instead of the field's description. One example is the dashboardpermissionsfield. Its validators said "Allows parameters to be defined in snake case, but passed as camel case." where they should say "Permissions that restrict users from editing dashboards".Correction to #141: that PR blamed
describeNullableValuesand its??=. That was wrong. The field description never reaches Hey API's IR. When anallOfhas a single member, Hey API's parser runsObject.assign(wrapper, member)(addItemsToSchemawithmutateSchemaOneItem), so the member's description overwrites the wrapper's. Non-nullable wrappers lose their description the same way, for example the detectorconditionGrouprequest field.Fix:
normalize-specnow inlines a single-memberallOfmember into its wrapper. It only does this when the wrapper's other keywords are annotations (description,nullable,readOnly,default, and similar). The wrapper's annotations win, and the member supplies the schema. A wrapper with other keywords, such asrequired, and anallOfwith more than one member are left alone.Effect on the current spec:
valibot.gen.tsand 23 inzod.gen.ts.types.gen.tschanges only in JSDoc comments. No types change.layoutused to show the member's "Widget grid layout position and dimensions… Constraints: x (0-5)…" and now shows the field's "Position and size of the widget on the dashboard grid." This matches the behavior for every other field: the field's own description wins.Tests:
test/normalize-spec.test.tscovers inlining an annotated wrapper and leaving constrained and multi-member wrappers alone.test/descriptions.test.tschecks the dashboardpermissionsfield against the spec's own field description. It fails without the fix.pnpm build,pnpm typecheckandpnpm testpass (658 tests). Locally the build neededNODE_OPTIONS=--max-old-space-size=4096because the sandbox only has 8 GB of RAM. CI is unchanged.via @BYK.
--
View Session in Sentry