Repository navigation
fix(models): degrade a non-object Codex auth file to no credential - #5584
Merged
WillemJiang merged 1 commit intoSep 19, 2026
Merged
WillemJiang merged 1 commit into
WillemJiang merged 1 commit into
Conversation
load_codex_cli_credential called .get on the parsed ~/.codex/auth.json (and $CODEX_AUTH_PATH) without checking that the top level is an object. _load_json_file returns any valid JSON value, so an array or scalar payload raised AttributeError out of CodexChatModel.model_post_init instead of the documented 'Codex CLI credential not found' error. Guard the top level the same way the sibling Claude loader and its own nested tokens guard do.
WillemJiang
approved these changes
Sep 19, 2026
1 task done
1 of 9 tasks
1 task
2 tasks done
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.
Why
load_codex_cli_credentialreads~/.codex/auth.json(or$CODEX_AUTH_PATH) through_load_json_file, which returns whateverjson.loadsproduced — any valid JSON value, not only an object. The loader then calleddata.get("tokens", {})on it directly (backend/packages/harness/deerflow/models/credential_loader.py:229-232).A syntactically valid auth file whose top level is not an object (an array, a string, a number) therefore raised
AttributeError: 'list' object has no attribute 'get'fromload_codex_cli_credential. Nothing catches it, so it propagated out ofCodexChatModel.model_post_init(openai_codex_provider.py:95), aborting model construction before the provider could raise its documentedValueError("Codex CLI credential not found. Expected ~/.codex/auth.json or CODEX_AUTH_PATH."). That is the opposite of the module's degrade-gracefully behaviour.The nested
tokensvalue already carries this guard (credential_loader.py:233-235), and the sibling Claude loader got the equivalent top-level guard in #5494 — the Codex top level was the one spot left uncovered.What changed
return None, so the loader falls through andCodexChatModelreaches its existing documented "Codex CLI credential not found" error instead of anAttributeError.backend/tests/test_credential_loader.py:test_load_codex_cli_credential_ignores_non_object_auth_file— parametrized over array / string / number payloads, assertsload_codex_cli_credential() is None.test_codex_chat_model_reports_missing_credential_for_non_object_auth_file— assertsCodexChatModelconstruction raises the documentedValueError.Surface area
CodexChatModel/ credential loading); no prompt-layer data channels affected.Bug fix verification
backend/tests/test_credential_loader.py::test_load_codex_cli_credential_ignores_non_object_auth_fileand::test_codex_chat_model_reports_missing_credential_for_non_object_auth_filemainand green on this branch? yes.main(unpatched):4 failed, 19 deselected in 0.97s—AttributeError: 'list' object has no attribute 'get'atcredential_loader.py:232.23 passed.Validation
cd backend && uv run pytest tests/test_credential_loader.py -q→ 23 passedcd backend && uv run pytest -m "not live" --ignore=tests/blocking_io tests/ -q→ 17551 passed, 199 skipped, 3 deselectedcd backend && uv run ruff check .→ All checks passed;uv run ruff format --check .→ 1545 files already formattedAI assistance
Tool(s) used: Claude Code
How you used it: The assistant located the unguarded call, wrote the regression tests, and ran the verification commands quoted above. I reviewed the diff and understand every line.