Skip to content

fix(dashboard): correct TOML round-trip corruption in codex config serializer - #1438

Merged
diegosouzapw merged 3 commits into
diegosouzapw:release/v3.7.0from
benzntech:fix/codex-toml-roundtrip
Apr 20, 2026
Merged

diegosouzapw merged 3 commits into
diegosouzapw:release/v3.7.0from
benzntech:fix/codex-toml-roundtrip

Conversation

@benzntech

Copy link
Copy Markdown
Contributor

Problem

The parseToml/toToml round-trip in codex-settings/route.ts corrupted the Codex config.toml, causing Codex to fail with parse errors like:

TOML parse error at line 41, column 18
   |
41 | status_line = "["model-with-reasoning", "context-remaining", "current-dir"]"
   |                  ^
unexpected key or value, expected newline

Root causes

  1. parseToml did not strip quotes from keys — TOML quoted keys like "gpt-5.3-codex" were stored with quotes intact. toToml then added another quote layer, producing ""gpt-5.3-codex"".

  2. toToml wrapped ALL values in double quotes — array values like ["a", "b"] became "["a", "b"]", which is invalid TOML. Boolean/number values were also incorrectly quoted.

Fix

  • Strip quotes from keys in parseToml (matching existing value dequoting behavior)
  • Add formatTomlValue() helper that:
    • Preserves TOML arrays unquoted (values starting with [ and ending with ])
    • Outputs booleans as true/false without quotes
    • Outputs numbers without quotes
    • Only wraps string values in double quotes

Testing

Verified with inline round-trip test: parsed -> serialized -> reparsed produces identical structure. Arrays, quoted keys with dots, and string values all survive the round-trip correctly.

Files changed

  • src/app/api/cli-tools/codex-settings/route.ts -- parseToml key dequoting + formatTomlValue for toToml

benzntech and others added 2 commits April 20, 2026 02:46
Auto-syncs main branch from upstream diegosouzapw/OmniRoute
every 6 hours. Also triggerable manually via workflow_dispatch.

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
…rializer

parseToml did not strip quotes from keys, so quoted TOML keys like
"gpt-5.3-codex" were stored with quotes intact. toToml then added
another quote layer producing ""gpt-5.3-codex"". Additionally,
toToml wrapped all values in double quotes, so array values like
["a", "b"] became "["a", "b"]" which is invalid TOML.

- Strip quotes from keys in parseToml (matching existing value behavior)
- Add formatTomlValue() to preserve arrays/booleans/numbers unquoted
- Only string values get double-quoted in toToml output

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
@benzntech
benzntech requested a review from diegosouzapw as a code owner April 19, 2026 23:14

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request improves TOML handling in the codex-settings API route by adding support for quoted keys during parsing and implementing a formatTomlValue helper to correctly serialize different data types like booleans, numbers, and arrays. A review comment correctly identified redundant code in the new formatting logic that should be simplified.

Comment on lines +74 to +75
if (typeof value === "string") return `"${value}"`;
return `"${value}"`;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

These lines are redundant as they perform the same operation regardless of whether value is a string. Removing the redundant check simplifies the logic.

Suggested change
if (typeof value === "string") return `"${value}"`;
return `"${value}"`;
return `"${value}"`;

@diegosouzapw
diegosouzapw changed the base branch from main to release/v3.7.0 April 20, 2026 00:07
@diegosouzapw
diegosouzapw merged commit 77f326e into diegosouzapw:release/v3.7.0 Apr 20, 2026
1 of 2 checks passed
@diegosouzapw diegosouzapw mentioned this pull request Apr 20, 2026
Poid-ZA pushed a commit to Poid-ZA/OmniRoute that referenced this pull request Aug 5, 2026
…rializer (diegosouzapw#1438)

Integrated into release/v3.7.0. Thanks @benzntech for this great contribution! 🎉 We've removed the unrelated sync-fork.yml file and it's now merged into the release branch.
muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 2026
…rializer (diegosouzapw#1438)

Integrated into release/v3.7.0. Thanks @benzntech for this great contribution! 🎉 We've removed the unrelated sync-fork.yml file and it's now merged into the release branch.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants