Repository navigation
fix(account): find Codex's session file when the hook's path does not match - #396
Merged
Merged
Conversation
… match The first real Codex session after #395 recorded no account, although its session file existed and held both IDs. The read only accepted a plain path under Codex's home, so a Windows extended path was rejected, and a missing path gave up. It now accepts the extended form, and when the path is missing or unusable it finds the file by the session ID in its name. The ID is checked first, so a crafted value cannot widen the search, and the search stays inside Codex's sessions folder. What Codex actually sent is not known, so which of the two was the cause is not proven. A real session after merge decides whether this fixed it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
The first real Codex session after #395 recorded no account, although its session file existed and held both IDs. Tool calls and the model were recorded normally.
What changed
_codex_session_accountonly accepted a plain path under Codex's home. It now:The session ID is validated before it is used in a search, so a crafted value such as
*or../../etccannot widen it. The search stays insidesessions/under Codex's home. A path outside that home is still refused and falls back to the ID.The cause is not proven
What Codex actually sends its hooks was not captured, so it could be the extended path or a missing path. This handles both. A real Codex session after merge decides whether it worked.
Checks
Run from this branch on Windows:
pytest -q: 2262 passed, 7 skippedruff check agentmetry tests: cleanagentmetry benchmark: 0 missed, 0 false positives15846a0915769d4a, with no frozen file touchedNot run: a real Codex session through the live hook with this code.
🤖 Generated with Claude Code