Repository navigation
fix(tracing): tolerate unescaped Windows paths in hook payloads - #198
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Cursor on Windows writes `transcript_path` with raw backslashes (`c:\Users\...`), which is invalid JSON, so every Cursor hook failed to parse and the installed hook silently swallowed the error. When strict parsing fails, treat invalid escapes as literal backslashes and restore accidental escapes (`\b`, `\f`, `\n`, `\r`, `\t`) in the transcript path field. Valid JSON still takes the strict path unchanged. Fixes #197 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
0e9f6f8 to
c239027
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c23902741d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "Codex (@codex) review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".
|
Fails in Windows CI. |
|
re-ran CI - it was a flake |
Fixes #197
I know this is a bug with cursor itself, but we need to workaround this for a customer. I've reached out to the cursor team to let them know.
Problem
On Windows, Cursor writes
transcript_pathinto the hook payload with raw backslashes ("c:\Users\..."). That isn't valid JSON, so everybt trace hook --source cursorcall failed withinvalid escape. The installed hook throws away output and errors, so the failure was silent and no Cursor trace was ever recorded.The root cause is a serialization bug in Cursor. This PR works around it in
bt trace hook.Fix
parse_hook_payloadinbt-daemon/src/hook.rs:serde_jsonparse first. Valid payloads take this path unchanged, so nothing changes once Cursor fixes the bug.\U,\.,\a,\uwithout 4 hex digits) as literal backslashes, then parse again. Properly escaped fields such astextwith\nor\"are untouched.--transcript-path-fieldfield only, turn control characters picked up from escape-like path segments (\b91a…,\new,\tmp) back into\b,\f,\n,\r,\t.Known limitations
\\server\share) in a raw path would collapse to\server\share, because\\is a valid escape. Cursor transcript paths live under the user's home directory, so this shouldn't happen in practice.transcript_pathhas been reported.bt trace doctor cursordoesn't check the capture path. Both would be worth a follow-up.Testing
textsurvives. Another test checks that valid JSON is unchanged and that unfixable payloads return the original error.cargo test --all-features,cargo clippy --all-targets -D warnings, andcargo fmt --checkall pass.🤖 Generated with Claude Code