Skip to content

fix(v0): validation was crashing when a conditional reaches into a undefined fieldset value#261

Merged
and-why merged 3 commits into
mainfrom
cpf-3408-fieldset-null-crashes-nested-validations
Jun 23, 2026
Merged

fix(v0): validation was crashing when a conditional reaches into a undefined fieldset value#261
and-why merged 3 commits into
mainfrom
cpf-3408-fieldset-null-crashes-nested-validations

Conversation

@sandrina-p

@sandrina-p sandrina-p commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

What

V0 crashes when a schema conditional reaches into a nested fieldset whose value is null/undefined. This happens for rows/payloads that omit a fieldset, throwing instead of validating.

Example

Schema with a conditional that reaches into the pet fieldset:

{
  "type": "object",
  "properties": {
    "pet": {
      "type": "object",
      "x-jsf-presentation": { "inputType": "fieldset" },
      "properties": {
        "species": { "type": "string", "enum": ["dog", "cat"] }
      }
    },
    "pet_name": { "type": "string" }
  },
  "allOf": [
    {
      "if": {
        "properties": {
          "pet": { "properties": { "species": { "const": "dog" } } }
        },
        "required": ["pet"]
      },
      "then": { "required": ["pet_name"] }
    }
  ]
}

Validating a value that omits the fieldset crashes:

form.handleValidation({ pet: null }) // TypeError: Cannot read properties of null (reading 'species')

Root cause

checkIfConditionMatchesProperties recurses into the fieldset with formValues["pet"] which has a null value, so then it crashes inside.

Fix

Coalesce to {} (formValues[name] ?? {}) so the nested condition evaluates instead of crashing.

REF CPF-3408.

🤖 co-written with Claude Code

… fieldset

checkIfConditionMatchesProperties recursed into a nested fieldset with
formValues[name], which throws when that required fieldset is null/undefined
(e.g. imported/edited rows that omit it). Coalesce to {} so the nested
condition evaluates instead of crashing on a null property access.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@sandrina-p sandrina-p changed the title fix(v0): prevent crash when a conditional reaches into a null/undefined fieldset fix(v0): validation was crashing when a conditional reaches into a undefined fieldset value Jun 22, 2026
Comment thread v0/package.json Outdated
@sandrina-p sandrina-p requested a review from brennj June 22, 2026 16:30
@sandrina-p sandrina-p self-assigned this Jun 22, 2026
@sandrina-p sandrina-p force-pushed the cpf-3408-fieldset-null-crashes-nested-validations branch from 48a1d88 to 86c8851 Compare June 22, 2026 16:39
@sandrina-p sandrina-p force-pushed the cpf-3408-fieldset-null-crashes-nested-validations branch from 86c8851 to 0bbe671 Compare June 22, 2026 16:40
@HanliTheron HanliTheron self-requested a review June 22, 2026 20:02
@and-why and-why merged commit 0d0041c into main Jun 23, 2026
3 checks passed
@and-why and-why deleted the cpf-3408-fieldset-null-crashes-nested-validations branch June 23, 2026 00:26
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.

3 participants