Skip to content

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

@alexcz-a11y

Description

@alexcz-a11y

Summary

When saving configuration changes through the Web UI Form Editor, all numeric fields (e.g., maxTokens, contextWindow, cost.*) under models.providers are serialized as strings instead of numbers. This causes config.set to reject the payload with "invalid config", while saving the exact same configuration via Raw Config or CLI succeeds.

Steps to Reproduce

  1. Add a custom model provider with numeric fields in openclaw.json (via Raw Config or CLI):
    {
      models: {
        providers: {
          xai: {
            baseUrl: "https://api.x.ai/v1",
            api: "openai-completions",
            models: [
              {
                id: "grok-4",
                name: "Grok 4",
                contextWindow: 131072,
                maxTokens: 8192,
                cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 }
              }
            ]
          }
        }
      }
    }
  2. Open the Web UI → Settings → Form Editor.
  3. Change any setting (does not need to be related to the model provider).
  4. Click Save.

Result: Error: invalid config

Root Cause

The Form Editor's <input> fields produce string values by default. When the form is serialized for config.set, numeric fields like maxTokens are sent as "8192" (string) instead of 8192 (number).

Server-side validation (validateConfigObjectWithPlugins) then rejects the payload:

path:    models.providers.xai.models.0.maxTokens
message: Invalid input: expected number, received string

Evidence

Added temporary console.error logging inside the config.set handler to capture validated.issues:

[DEBUG config.set] validation issues: [
  {
    "path": "models.providers.xai.models.0.maxTokens",
    "message": "Invalid input: expected number, received string"
  }
]

Meanwhile, submitting the identical config file content via CLI succeeds:

openclaw gateway call config.set --params '{"raw": "<file contents>", "baseHash": "<hash>"}'
# ✓ succeeds — all numeric fields are correctly typed in the JSON file

Expected Behavior

The Form Editor should coerce values to their schema-defined types (number, boolean, etc.) before submitting to config.set. Alternatively, the config.set handler could coerce known numeric fields from strings.

Workaround

Use Raw Config editor instead of Form Editor to save configuration changes.

Environment

  • OpenClaw: 2026.2.9 (gateway) / 2026.2.1 (service unit)
  • OS: Ubuntu 25.04 (VPS)
  • Node: v22.x
  • Browser: safari (macOS)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions