fix(codex-migration): three bugs in codex config.toml generation (#26250) - #26259
Closed
zccyman wants to merge 0 commit into
Closed
fix(codex-migration): three bugs in codex config.toml generation (#26250)#26259zccyman wants to merge 0 commit into
zccyman wants to merge 0 commit into
Conversation
Contributor
Author
|
Thanks @NishantEC for taking a look! 🙏 |
zccyman
force-pushed
the
fix/codex-migration-three-bugs-26250
branch
from
May 18, 2026 00:43
40a487a to
43e566f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes three independent bugs in
codex_runtime_plugin_migration.pythat combine to produce a~/.codex/config.tomlthat codex refuses to load withduplicate keyerrors.Closes #26250
Bug A —
default_permissionsinside open[mcp_servers.*]table scopeRoot cause:
render_codex_toml_section()emitteddefault_permissionsinside the managed block. When the block is appended after user-owned[mcp_servers.*]tables, TOML's lexer treatsdefault_permissions = ":workspace"as a key of the most-recent table header. On re-migration, the duplicate key triggers codex's strict Toml parser.Fix: Move
default_permissionsemission to the top ofmigrate(), prepending it at the very top of the rewritten config — before any table header opens.Bug B —
[plugins."<name>@<marketplace>"]tables duplicated on re-runRoot cause:
_strip_existing_managed_block()only removes content betweenMIGRATION_MARKERandMIGRATION_END_MARKER. Plugin entries written by codex itself (outside the markers) survive the strip._query_codex_plugins()emits fresh[plugins.X]entries, producing duplicates.Fix: Add
_scan_existing_plugins()that scans the un-managed content for existing[plugins.X]entries.migrate()filters them out before re-emitting.Bug C —
HERMES_HOMEfromos.environleaks into user's configRoot cause:
_build_hermes_tools_mcp_entry()burnsHERMES_HOMEandPYTHONPATHfromos.environinto the[mcp_servers.hermes-tools]env dict. This persists stale paths (e.g. a long-deleted pytest tempdir or old profile path) into the user's~/.codex/config.toml.Fix: Remove
HERMES_HOMEandPYTHONPATHfrom the rendered env dict. The MCP subprocess inherits the parent's environment when codex spawns it — no need to hardcode at migrate-time.Files Changed
hermes_cli/codex_runtime_plugin_migration.pyTest Results
Design Decisions
[hermes]table — TOML'sdefault_permissionsis a top-level key. Wrapping it in[hermes]would break codex's schema. Prepend before any table header is the only scope-safe approach.[plugins.*]from the file would delete user-managed codex plugins. Scan-and-filter is safer.HERMES_HOME/PYTHONPATHbecause codex spawns it as a subprocess that inherits the active environment.