Skip to content

fix(account): find Codex's session file when the hook's path does not match - #396

Merged
blitzcrieg1 merged 1 commit into
masterfrom
fix/codex-account-path
Nov 7, 2026
Merged

blitzcrieg1 merged 1 commit into
masterfrom
fix/codex-account-path

Conversation

@blitzcrieg1

Copy link
Copy Markdown
Owner

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_account only accepted a plain path under Codex's home. It now:

  • accepts the Windows extended form of a path
  • finds the session file by the session ID in its name when the path is missing or unusable

The session ID is validated before it is used in a search, so a crafted value such as * or ../../etc cannot widen it. The search stays inside sessions/ 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 skipped
  • ruff check agentmetry tests: clean
  • agentmetry benchmark: 0 missed, 0 false positives
  • Fingerprint: 15846a0915769d4a, with no frozen file touched
  • On real session files, showing keys only: IDs found by session ID alone, by the extended path and by a plain path, in about 2 ms. Nothing found when given nothing usable

Not run: a real Codex session through the live hook with this code.

🤖 Generated with Claude Code

… 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>
@blitzcrieg1
blitzcrieg1 merged commit c7c9dad into master Nov 7, 2026
11 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 7, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant