Skip to content

omx setup leaves invalid TOML when existing root notify uses multiline array #1401

Description

@ysyecust

Summary

Running omx setup against a Codex config.toml that already has a multiline root-level notify = [ ... ] array can produce invalid TOML.

Reproduction

Given an existing ~/.codex/config.toml root section like:

approval_policy = "on-request"
sandbox_mode = "workspace-write"
web_search = "live"
notify = [
  "terminal-notifier",
  "-title", "Codex ECC",
  "-message", "Task completed!",
  "-sound", "default",
]
persistent_instructions = "Follow project AGENTS.md guidelines."

Run:

omx setup

Actual Result

The merged config keeps the tail of the original multiline array after inserting the OMX-managed notify line, producing invalid TOML like:

notify = ["node", "/path/to/notify-hook.js"]
...
web_search = "live"
  "terminal-notifier",
  "-title", "Codex ECC",
  "-message", "Task completed!",
  "-sound", "default",
]

Codex then fails to start with an error such as:

Error loading configuration: ~/.codex/config.toml:6:9: key with no value, expected `=`

Expected Result

omx setup should fully remove or replace the existing root-level notify value, including multiline arrays, and leave a valid TOML file.

Root Cause

In dist/config/generator.js, stripRootLevelKeys() removes only the notify = ... first line for managed root keys. It does not remove the following lines when the value is a multiline array.

The problematic logic is around:

  • stripRootLevelKeys()
  • buildMergedConfig() calling stripOmxTopLevelKeys(existing) before reinserting OMX-managed top-level keys

Minimal Fix

When a managed root key starts an array value like notify = [, the stripper should continue discarding lines until the closing ] is reached.

Workaround

Keep notify as a single-line value before running omx setup, or remove the existing multiline notify block before setup.

Extra Context

I locally patched stripRootLevelKeys() to discard multiline arrays for managed root keys, and the issue stopped reproducing. The patched merge output parsed successfully as TOML and codex login status worked again.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions