Skip to content

fix(ui): coerce form values to schema types before config.set#13468

Merged
gumadeiras merged 3 commits intoopenclaw:mainfrom
mcaxtr:fix/13348-form-editor-number-coerce
Feb 11, 2026
Merged

fix(ui): coerce form values to schema types before config.set#13468
gumadeiras merged 3 commits intoopenclaw:mainfrom
mcaxtr:fix/13348-form-editor-number-coerce

Conversation

@mcaxtr
Copy link
Contributor

@mcaxtr mcaxtr commented Feb 10, 2026

Summary

Fixes #13348

HTML <input> elements always produce string .value properties. While the form
rendering code converts most values correctly, some interactions (map-field
repopulation, re-renders, paste) can leak raw strings into configForm state.
When these string values are serialized and sent to config.set, the gateway's
Zod validation rejects them because it expects numbers/booleans.

This PR adds a coerceFormValues() utility that walks the form object tree
alongside the JSON Schema and converts string values back to their schema-defined
types (number, integer, boolean) before serialization. It's called in the new
serializeFormForSubmit() helper used by both saveConfig and applyConfig.

Changes

  • New: ui/src/ui/controllers/config/form-coerce.ts — recursive schema-aware
    type coercion (handles objects, arrays, anyOf/oneOf, additionalProperties)
  • Modified: ui/src/ui/controllers/config.ts — added serializeFormForSubmit()
    that coerces form values before JSON serialization
  • New: ui/src/ui/controllers/config/form-utils.node.test.ts — 10 tests
    covering coercion of numbers, booleans, integers, empty strings, anyOf unions,
    null/undefined passthrough, and non-numeric string rejection

Test plan

  • All 10 new tests fail before the fix, pass after
  • pnpm build passes
  • pnpm check passes (format + typecheck + lint)
  • CI green

Greptile Overview

Greptile Summary

This PR fixes a form submission typing bug by coercing stringly-typed form state back into schema-defined JSON types before submitting to config.set/config.apply. It introduces a recursive coerceFormValues() walker keyed off the existing JsonSchema shape (including objects, arrays, anyOf/oneOf, and additionalProperties), then routes both save/apply through a shared serializeFormForSubmit() helper in ui/src/ui/controllers/config.ts.

New node-level tests exercise numeric/boolean coercion, empty-string clearing behavior, nullable(anyOf) recursion, tuple arrays, and preservation of already-correct values.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk.
  • Changes are localized to config form submission serialization, add a dedicated schema-driven coercion helper, and include targeted tests covering the previously reported edge cases (nullable unions, tuple arrays, empty-string clearing). No additional behavior changes were found outside the submission path.
  • No files require special attention

@openclaw-barnacle openclaw-barnacle bot added the app: web-ui App: web-ui label Feb 10, 2026
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

1 file reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

@mcaxtr mcaxtr force-pushed the fix/13348-form-editor-number-coerce branch from f7556b4 to fd74e16 Compare February 10, 2026 15:27
@mcaxtr
Copy link
Contributor Author

mcaxtr commented Feb 10, 2026

@greptile please re-review this PR.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

1 file reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

@mcaxtr mcaxtr force-pushed the fix/13348-form-editor-number-coerce branch from fd74e16 to 750e0c5 Compare February 10, 2026 15:40
@mcaxtr
Copy link
Contributor Author

mcaxtr commented Feb 10, 2026

@greptile please re-review this PR.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@mcaxtr mcaxtr force-pushed the fix/13348-form-editor-number-coerce branch from 750e0c5 to 42af507 Compare February 10, 2026 15:57
@mcaxtr
Copy link
Contributor Author

mcaxtr commented Feb 10, 2026

@greptile please re-review this PR.

@mcaxtr
Copy link
Contributor Author

mcaxtr commented Feb 10, 2026

Note: #13452 also targets this issue with a different approach (coercing at input time in updateConfigFormValue). This PR coerces at serialization time in serializeFormForSubmit, which prevents re-renders from re-introducing string leaks into form state.

@mcaxtr mcaxtr force-pushed the fix/13348-form-editor-number-coerce branch from 42af507 to 47f8e9e Compare February 11, 2026 03:36
@gumadeiras gumadeiras self-assigned this Feb 11, 2026
mcaxtr and others added 2 commits February 11, 2026 01:02
…zation

HTML <input> elements produce string .value properties, so numeric and boolean
config fields can leak into configForm as strings.  Add coerceFormValues() that
walks the form object tree alongside the JSON Schema and converts string values
back to their schema-defined types before JSON serialization.

Fixes openclaw#13348
@gumadeiras gumadeiras force-pushed the fix/13348-form-editor-number-coerce branch from 47f8e9e to 61feb7e Compare February 11, 2026 06:07
@gumadeiras gumadeiras merged commit 841dbee into openclaw:main Feb 11, 2026
23 checks passed
zapabob pushed a commit to zapabob/clawdbot that referenced this pull request Feb 11, 2026
shan-mx pushed a commit to shan-mx/openclaw that referenced this pull request Feb 11, 2026
michaelleone pushed a commit to michaelleone/openclaw that referenced this pull request Feb 11, 2026
Patrick3131 added a commit to Patrick3131/openclaw that referenced this pull request Feb 11, 2026
* main: (936 commits)
  fix: use configured base URL for Ollama model discovery (openclaw#14131)
  docs: modernize gateway configuration page (Phase 1) (openclaw#14111)
  docs(skills): update mintlify skill to reference docs/ directory (openclaw#14125)
  chore: update AGENTS.md and add mintlify skill (openclaw#14123)
  chore(irc): sync plugin version to 2026.2.10
  fix(cli): drop logs --localTime alias noise
  fix(config): avoid redacting maxTokens-like fields (openclaw#14006)
  feat: Add --localTime option to logs command for local timezone display (openclaw#13818)
  fix: don't lowercase Slack channel IDs (openclaw#14055)
  fix(plugins): ignore install scripts during plugin/hook install
  fix(gateway): default-deny missing connect scopes
  fix(web-search): handle xAI Responses API format in Grok provider
  Feat/litellm provider (openclaw#12823)
  docs: start 2026.2.10 changelog section
  chore: bump version to 2026.2.10
  docs: remove outdated pricing information
  docs: add Terraform IaC approach to Hetzner guide
  fix(ui): coerce form values to schema types before config.set (openclaw#13468)
  chore: make merge PR comment mandatory + skill name fix
  🤖 memory-lancedb: avoid plugin-sdk enum helper in local TypeBox schema (openclaw#13897)
  ...
@mcaxtr mcaxtr deleted the fix/13348-form-editor-number-coerce branch February 12, 2026 00:29
GoddessSerenity pushed a commit to GoddessSerenity/openclaw that referenced this pull request Feb 12, 2026
Takhoffman pushed a commit to tomsun28/openclaw that referenced this pull request Feb 12, 2026
sauerdaniel pushed a commit to sauerdaniel/openclaw that referenced this pull request Feb 12, 2026
dbachelder pushed a commit to dbachelder/openclaw that referenced this pull request Feb 13, 2026
Baukebrenninkmeijer pushed a commit to orq-ai/openclaw that referenced this pull request Feb 13, 2026
skyhawk14 pushed a commit to skyhawk14/openclaw that referenced this pull request Feb 13, 2026
cloud-neutral pushed a commit to cloud-neutral-toolkit/openclawbot.svc.plus that referenced this pull request Feb 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Web UI Form Editor serializes number fields as strings, causing config.set validation failure

2 participants

Comments