timkindberg / timkindberg/formframe

oneOf detection too broad: only a simple const-oneOf is choices; a deep oneOf is a variant/section selector

Open
#85 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

deferred p3 type:bug
Dominant language
TypeScript
Stars
1
Forks
0
Avg merge
2d 11h
Merged PRs (30d)
4

Description

Discovered during 4j1 demo work (App_14 oneOf multiselect + App_01 country select).

BUG: the parser treats ANY oneOf as a finite set of choices:

  • packages/core/src/parser/arrayNode.ts isPrimitiveArraySchema(): if (itemsSchema.enum || itemsSchema.oneOf) return true -> the whole array becomes a multiselect FieldNode.
  • packages/core/src/parser/fieldNode.ts createFieldNode(): hasOneOf -> isSelect; buildSelectOptions() maps oneOf branches, filtering ('const' in item).

But oneOf is also (more commonly) a STRUCTURAL union: branches that are object subschemas (discriminated union) meant to swap out whole form sections, e.g. items.oneOf = [ {type:object, properties:{...A}}, {type:object, properties:{...B}} ]. Those branches have no const, so today they are FILTERED OUT -> an empty-options multiselect. The array never becomes an add/remove ArrayNode either, so the entire variant structure is silently dropped.

Only a SIMPLE oneOf should be treated as choices: every branch is a scalar constant (has const, primitive value), i.e. an enum-with-labels exactly like App_01 country ([{const:'US',title:'United States'}, ...]).

FIX (parser-side, front-end concern): gate the "oneOf -> choices" detection on ALL branches being simple const entries. If any branch is object/array/$ref/typed-without-const, it is NOT choices — treat it as a (currently unsupported) union/variant selector, a separate feature (discriminated-union / section-swap). At minimum, do not mis-collapse it into an empty multiselect.

Lower priority (per Tim). No consumer hits it until deep-oneOf schemas are used.

Relationships

  • Discovered from: jsonschema-form-4j1 (not migrated)

bd: jsonschema-form-aml

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in packages/core/src/parser/arrayNode.ts and packages/core/src/parser/fieldNode.ts, tracing isPrimitiveArraySchema(), createFieldNode(), and buildSelectOptions(). Check the App_01 simple const-oneOf and the App_14 deep object-oneOf cases; done means scalar const branches remain choices while structural branches are not collapsed into an empty multiselect.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.