Skip to content

fix(validators): Keep the field description of single-member allOf fields - #142

Merged
BYK merged 1 commit into
mainfrom
fix/nullable-field-descriptions
Nov 9, 2026
Merged

BYK merged 1 commit into
mainfrom
fix/nullable-field-descriptions

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

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 dashboard permissions field. 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 describeNullableValues and its ??=. That was wrong. The field description never reaches Hey API's IR. When an allOf has a single member, Hey API's parser runs Object.assign(wrapper, member) (addItemsToSchema with mutateSchemaOneItem), so the member's description overwrites the wrapper's. Non-nullable wrappers lose their description the same way, for example the detector conditionGroup request field.

Fix: normalize-spec now inlines a single-member allOf member 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 as required, and an allOf with more than one member are left alone.

Effect on the current spec:

  • 23 field descriptions change in valibot.gen.ts and 23 in zod.gen.ts. types.gen.ts changes only in JSDoc comments. No types change.
  • Tradeoff: a few fields swap a longer member description for a shorter field description. For example, the dashboard widget layout used 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:

  • A unit test in test/normalize-spec.test.ts covers inlining an annotated wrapper and leaving constrained and multi-member wrappers alone.
  • A regression test in test/descriptions.test.ts checks the dashboard permissions field against the spec's own field description. It fails without the fix.
  • pnpm build, pnpm typecheck and pnpm test pass (658 tests). Locally the build needed NODE_OPTIONS=--max-old-space-size=4096 because the sandbox only has 8 GB of RAM. CI is unchanged.

via @BYK.

--

View Session in Sentry

…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>
@BYK
BYK merged commit 8e538bb into main Nov 9, 2026
11 checks passed
@BYK
BYK deleted the fix/nullable-field-descriptions branch November 9, 2026 21:27

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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.

Comment thread lib/normalize-spec.mjs
Object.assign(node, allOf[0], annotations);
}
Object.values(node).forEach(inlineAnnotatedAllOf);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 9fa9fad. Configure here.

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.

1 participant