Skip to content

Config validation errors should show line number, bad value, and bracket notation for array indices #104854

Description

@ekinnee

Problem

When openclaw.json has an invalid enum value (e.g. tools.profile: "none"), the error message says:

agents.list.3.tools.profile: Invalid input (allowed: "minimal", "coding", "messaging", "full")

Three things make this hard to debug:

  1. No line number — you can't grep or vim /none to find the offending value
  2. No bad value shown — Zod's invalid_enum_value error already carries a received field (e.g. "none"), but it's silently dropped before formatting
  3. Array index as dot-segmentagents.list.3 looks like a property path, not an array index. Should be agents.list[3]

Expected

openclaw.json:247 — agents.list[3].tools.profile: Invalid input, got: "none" (allowed: "minimal", "coding", "messaging", "full")

That's grep-able, tells you exactly what you set wrong, and points to the line.

Implementation sketch

  • formatConfigPath() in src/config/validation.ts — use bracket notation for numeric segments
  • mapZodIssueToConfigIssue() — read Zod's received field and append got: ${JSON.stringify(received)}
  • runConfigValidate() in src/cli/config-cli.ts — walk the Zod error path against the raw file text (already available in ConfigFileSnapshot.raw) to find the line number

Related

  • ConfigFileSnapshot already has raw: string | null — the full raw file text
  • ConfigValidationIssue type in src/config/types.openclaw.ts — could add an optional line field

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low-priority cleanup, docs, polish, ergonomics, or speculative work.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:ux-frictionUser-facing flow adds avoidable confusion or support burden without fully blocking progress.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.maturity:stableIssue affects a taxonomy feature currently scored M4/M5.no-staleExclude from stale automation

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions