Skip to content

Fix crash when an if.required field has a json-logic validation - #273

Merged
thiamsantos merged 2 commits into
mainfrom
fix-if-required-drops-jsonlogic-context
Sep 11, 2026
Merged

thiamsantos merged 2 commits into
mainfrom
fix-if-required-drops-jsonlogic-context

Conversation

@thiamsantos

@thiamsantos thiamsantos commented Sep 8, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Fixes a crash when a form field appears in a conditional's required list and also has a json-logic validation.

Why

createHeadlessForm threw required validation "" doesn't exist for a valid schema, so the form could not be built or validated. The named validation was defined at the schema root the whole time; the conditional's type-error check could not see it. This blocked any schema that pairs if.required with x-jsf-logic-validations on the same field.

How

forward jsonLogicContext (already in scope) and a path into that validateSchema call.


Note

Low Risk
Single-argument change on an internal conditional type-check path; behavior is narrowed to schemas that combine if.required with json-logic validations on the same field.

Overview
Fixes a build/validation crash when a field listed in a conditional’s if.required also declares x-jsf-logic-validations. The type-error gate inside evaluateConditional now passes the existing jsonLogicContext (and path) into validateSchema, so json-logic rules resolve from the root schema instead of throwing that a named validation “doesn’t exist.”

Adds a fixture and tests for field_a with both if.required and a_at_least_ten: form creation no longer throws, the then branch still requires field_c alongside logic errors, and the else branch still hides field_c while logic validation runs.

Reviewed by Cursor Bugbot for commit a828b20. Bugbot is set up for automated code reviews on this repo. Configure here.

@thiamsantos
thiamsantos force-pushed the fix-if-required-drops-jsonlogic-context branch 2 times, most recently from 47d1fa6 to fa2c83b Compare September 8, 2026 17:32
@thiamsantos
thiamsantos marked this pull request as ready for review September 8, 2026 17:56
@thiamsantos
thiamsantos requested a review from eshiota September 8, 2026 17:59
@thiamsantos thiamsantos self-assigned this Sep 8, 2026
@thiamsantos
thiamsantos force-pushed the fix-if-required-drops-jsonlogic-context branch from fa2c83b to a828b20 Compare September 10, 2026 17:52
@thiamsantos
thiamsantos requested a review from brennj September 10, 2026 17:53
@thiamsantos
thiamsantos merged commit 14d4c3b into main Sep 11, 2026
6 checks passed
@thiamsantos
thiamsantos deleted the fix-if-required-drops-jsonlogic-context branch September 11, 2026 17:37
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.

2 participants