Skip to content

fix(utils): preserve boolean conditional branches in retrieveSchema#5101

Open
nkgotcode wants to merge 2 commits into
rjsf-team:mainfrom
nkgotcode:main
Open

fix(utils): preserve boolean conditional branches in retrieveSchema#5101
nkgotcode wants to merge 2 commits into
rjsf-team:mainfrom
nkgotcode:main

Conversation

@nkgotcode

Copy link
Copy Markdown

Summary

  • convert matched boolean if/then/else branches to their schema equivalents during retrieveSchema() resolution
  • add a utils regression covering then: false
  • add a core regression proving submit is blocked when the matched branch resolves to an impossible schema

Test plan

  • cd packages/utils && npm run build
  • cd packages/utils && npx vitest run -c vitest.config.ts test/schema.test.ts --reporter=dot --coverage.enabled=false
  • cd packages/validator-ajv8 && npm run build
  • cd packages/core && npx vitest run -c vitest.config.ts test/validate.test.tsx --reporter=dot

Closes #4528

nkgotcode and others added 2 commits June 1, 2026 17:52
- convert matched boolean if/then/else branches to schema equivalents
- add utils regression for then: false
- add core submit regression for blocked form submission

Fixes rjsf-team#4528

@heath-freenome heath-freenome left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you please update the CHANGELOG. md with an appropriate comment in the @rjsf/utils section

{ [REF_KEY]: get(schema.additionalProperties, [REF_KEY]) } as S,
rootSchema,
formData as T,
get(formData, [key]) as T,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Was this a bug fix that you found in addition to the changes above? If so, then I would suggest making sure there is a test to validate it.


describe('getTestIds', () => {
describe('process.env.NODE_ENV === "test"', () => {
let oldNodeEnv: string | undefined;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Was there a test issue here? Or did you do this for correctness?

if (branch === undefined) {
return undefined;
}
return (typeof branch === 'boolean' ? (branch ? {} : { not: {} }) : branch) as S;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Since the (branch ? {} : { not: {} }) : branch) as S; logic already exists in relaxOptionsForScoring() maybe it makes sense to refactor it into a small helper function used in both places?

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.

Boolean schema false is ignored

2 participants