openclaw - 💡(How to fix) Fix config patch/set coerce numeric-string object keys into array indices

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

openclaw config patch and openclaw config set coerce all-digit string keys into array indices. This breaks valid Record-typed config paths such as channels.discord.guilds, where Discord snowflake IDs are string keys but look numeric.

Error Message

Error: Config validation failed: channels.discord.guilds: invalid config: must be object

Root Cause

Discord guild IDs are all-digit strings by design. Any Record-typed config that accepts numeric IDs becomes hard or impossible to write through the CLI patch/set path, even though the on-disk JSON shape is valid and the runtime reader handles it correctly.

Fix Action

Fix / Workaround

Summary

openclaw config patch and openclaw config set coerce all-digit string keys into array indices. This breaks valid Record-typed config paths such as channels.discord.guilds, where Discord snowflake IDs are string keys but look numeric.

Reproduction

Create two minimal patch files:

openclaw config patch --dry-run /tmp/probe-array.json5
openclaw config patch --dry-run /tmp/probe-string.json5
openclaw config set "channels.discord.guilds.1495587801394184362.requireMention" true

Code Example

cat > /tmp/probe-array.json5 <<'EOF1'
{ channels: { discord: { guilds: { "1495587801394184362": { requireMention: true } } } } }
EOF1
cat > /tmp/probe-string.json5 <<'EOF2'
{ channels: { discord: { guilds: { "test-guild": { requireMention: true } } } } }
EOF2

---

openclaw config patch --dry-run /tmp/probe-array.json5
openclaw config patch --dry-run /tmp/probe-string.json5
openclaw config set "channels.discord.guilds.1495587801394184362.requireMention" true

---

Error: Config validation failed: channels.discord.guilds: invalid config: must be object
RAW_BUFFERClick to expand / collapse

Summary

openclaw config patch and openclaw config set coerce all-digit string keys into array indices. This breaks valid Record-typed config paths such as channels.discord.guilds, where Discord snowflake IDs are string keys but look numeric.

Environment

  • OpenClaw version: 2026.5.7
  • Install path: native install via the official one-liner
  • Host OS: Ubuntu 24.04

Reproduction

Create two minimal patch files:

cat > /tmp/probe-array.json5 <<'EOF1'
{ channels: { discord: { guilds: { "1495587801394184362": { requireMention: true } } } } }
EOF1
cat > /tmp/probe-string.json5 <<'EOF2'
{ channels: { discord: { guilds: { "test-guild": { requireMention: true } } } } }
EOF2

Then run:

openclaw config patch --dry-run /tmp/probe-array.json5
openclaw config patch --dry-run /tmp/probe-string.json5
openclaw config set "channels.discord.guilds.1495587801394184362.requireMention" true

Expected

Numeric-looking string keys should remain string keys for Record/object fields. Both patch and set operations should preserve the object shape of channels.discord.guilds.

Actual

The numeric-key patch fails validation:

Error: Config validation failed: channels.discord.guilds: invalid config: must be object

The non-numeric key patch passes, which suggests the failure is caused by numeric-key coercion rather than the value shape.

config set shows the same class of failure for the same reason.

Why this matters

Discord guild IDs are all-digit strings by design. Any Record-typed config that accepts numeric IDs becomes hard or impossible to write through the CLI patch/set path, even though the on-disk JSON shape is valid and the runtime reader handles it correctly.

Suggested fix

  • Preserve key types from JSON/JSON5 input for Record/object schema fields.
  • Do not apply array-index heuristics to object keys solely because they are all digits.
  • Ensure config set path parsing can target string-keyed object members whose keys are numeric strings.

Notes

AoAOS workaround: write the final config atomically with Python/JSON instead of using the CLI patch path. Source doc:

  • docs/upstream-bugs/config-patch-numeric-key-array-coercion.md

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix config patch/set coerce numeric-string object keys into array indices