fix: normalize Windows extended-length paths in import ledger lookup (#513)#551
Open
AndrewAvery7 wants to merge 1 commit into
Open
fix: normalize Windows extended-length paths in import ledger lookup (#513)#551AndrewAvery7 wants to merge 1 commit into
AndrewAvery7 wants to merge 1 commit into
Conversation
importedThreadIdForSource compared fs.realpathSync output against ledger source_path records with strict equality. On Windows, Codex writes ledger paths with the \?\ extended-length prefix while realpathSync returns the plain form, so the comparison never matched: every successful transfer was reported as 'did not record an imported thread' (openai#513). Normalize both sides before comparing: strip \?\ (and \?\UNC\), and compare case-insensitively on win32. Fixes openai#513 Co-Authored-By: Claude Fable 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 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.
Problem
On Windows,
/codex:transferalways reports:even though the thread is actually created (#513; likely also the root cause behind #417 / #514 reports on Windows).
Root cause
importedThreadIdForSource()inplugins/codex/scripts/lib/codex.mjscompares the ledger'ssource_pathagainstfs.realpathSync(sourcePath)with strict string equality. On Windows, Codex writes ledger records with the extended-length path prefix:{ "source_path": "\\?\C:\Users\<user>\.claude\projects\...\session.jsonl", ... }while
realpathSyncreturns the plain form (C:\Users\<user>\...). The two never compare equal, so the lookup returnsnulland the command reports a false failure.Fix
Add
normalizeLedgerPath(): strip the extended-length prefix (both the drive form\\?\C:\...and the network form\\?\UNC\server\share\...) from both sides of the comparison, and compare case-insensitively onwin32. Non-Windows behavior is unchanged (identity comparison, exactly as before).Testing
node --checkpasses on the modified module.Fixes #513
🤖 Generated with Claude Code