Skip to content

ocx sync and restore back fail permanently with an unnamed config issue, leaving the Codex catalog truncated and routing un-injected #1453

Description

@MarcusNeufeldt

Client or integration

Codex CLI

Area

CLI

Summary

ocx sync and ocx restore back fail permanently on my install with a message that names no reason:

Codex sync did not complete. Fix the reported Codex config issue and retry.
Plain `codex` was not switched back to opencodex. Fix the reported Codex config issue and retry.

No "Codex config issue" is ever printed — not on stdout, not on stderr, and ocx doctor reports every check ok. There is nothing to act on, so the instruction "fix the reported issue and retry" cannot be followed.

This has two compounding consequences, because of the ordering documented in src/cli/index.ts:

// Only warn/restart when a catalog or models_cache write actually happened. This is
// deliberately not an `else`: refreshCodexModelCatalog runs before injectCodexConfig,
// so a sync can fail (`ok: false`) after the catalog was already rewritten
  1. The model catalog is rewritten before the injection fails, so it is left truncated. My proxy serves 435 models (200 native, 157 openrouter/opencode-go, 43 Anthropic, 35 Google) but opencodex-catalog.json contains only 9, all OpenAI-family. The non-OpenAI models are reachable through the proxy but never appear in Codex.
  2. Routing is never restored. ocx stop and ocx update both remove the injected openai_base_url and model_catalog_json root keys. Since sync / restore back can never complete, nothing puts them back. After every update I have to re-add them by hand from <CODEX_HOME>/opencodex.config.toml.

Expected: either the sync succeeds, or the specific config problem is printed so it can be fixed. Ideally the catalog would also not be rewritten until the injection is known to succeed.

Reproduction

100% reproducible on my install, across ocx update, full restarts of the proxy, and two different versions (2.11.0 and 2.12.0).

  1. Have opencodex injected into Codex (openai_base_url + model_catalog_json present in <CODEX_HOME>/config.toml).
  2. Run ocx stop (or ocx update, which stops as its first step). The two injected root keys are removed.
  3. Start the proxy again and confirm it is healthy (/healthz → 200, /v1/models → full list).
  4. Run ocx restore back → fails with the message above.
  5. Run ocx sync → fails with the message above.
  6. Inspect opencodex-catalog.json → rewritten, but containing only the OpenAI-family models.

The proxy is healthy throughout. The only way I have found to restore routing is editing config.toml manually using the keys documented in <CODEX_HOME>/opencodex.config.toml.

Things I ruled out

To save triage time, I checked the obvious candidates and none of them apply:

  • Config is valid UTF-8 — strict TextDecoder('utf-8', {fatal: true}) decode succeeds.
  • No duplicate TOML tables — 185 [projects.*] entries, zero duplicate keys.
  • Size is modest — 33,524 bytes.
  • Proxy is healthy/healthz 200, /v1/models returns 435 entries, live requests succeed.
  • ocx doctor is entirely clean — every check ok, including "Codex restart safety", "Project Codex configs", and "OAuth reliability".
  • Not the stripped keys themselves — the failure persists identically after routing is manually restored and verified working end-to-end.

Not a duplicate of the nearby catalog issues

Suggested fixes

  1. Print the actual reason. syncModelsToCodex returns ok: false but the caller only prints a generic sentence referring to a "reported" issue that is never reported. Surfacing the underlying error would make this self-service.
  2. Do not rewrite the catalog before the injection is known to succeed, or roll the catalog back when injection fails — otherwise a failed sync actively degrades a working install by truncating the model list.
  3. Consider having ocx doctor exercise the same code path, since it currently reports a fully healthy system while sync cannot complete.

Version

2.12.0 (also reproduced on 2.11.0)

Operating system

Windows 11 Pro 10.0.26200

Provider and model

Proxy serves 435 models across openai (native), openrouter, opencode-go and anthropic; the Codex-facing catalog is reduced to 9 OpenAI-family entries.

Logs or error output

$ ocx sync
Codex sync did not complete. Fix the reported Codex config issue and retry.

$ ocx restore back
Plain `codex` was not switched back to opencodex. Fix the reported Codex config issue and retry.

$ ocx sync-cache
WARNING: 4 Codex app-server process(es) still running (PIDs: ...). Disk catalog/cache were
updated, but Codex may keep showing the old model list until those processes restart.
# catalog still contains 9 models afterwards

$ ocx doctor
# every section reports ok, including:
#   Codex restart safety      ok
#   Project Codex configs     ok     no project-local provider bypass detected
#   OAuth reliability         [OK] x3

# proxy is healthy and multi-provider the whole time:
GET /healthz      -> 200
GET /v1/models    -> 435 models
   {"openai-native":200,"opencode-go/openrouter-other":157,"anthropic":43,"google":35}

# but the Codex-facing catalog:
<CODEX_HOME>/opencodex-catalog.json -> {"models": [ ...9 entries, all OpenAI-family... ]}

Screenshots and supporting files

No response

Redacted configuration

{
  "providers": {
    "openai":  { "adapter": "openai-responses", "codexAccountMode": "direct", "authMode": "forward" },
    "openrouter": { "adapter": "openai-chat", "baseUrl": "https://openrouter.ai/api/v1" },
    "opencode-go": { "adapter": "openai-chat", "baseUrl": "https://opencode.ai/zen/go/v1" },
    "anthropic": { "adapter": "anthropic", "authMode": "oauth" }
  },
  "defaultProvider": "openrouter",
  "activeCodexAccountId": "__main__"
}

<CODEX_HOME>/config.toml is 33 KB with 185 [projects.*] trust entries, valid UTF-8, no duplicate keys.

Checks

  • I searched existing issues and documentation.
  • I removed secrets, tokens, account details, request credentials, and personal data.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcatalogModel catalog, slugs, visibility, routed entriescliCLI, config inject, packaging flags

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions