Skip to content

fix(projects): strip ephemeral proxy prefix from project_id - #13

Open
GetsEclectic wants to merge 1 commit into
dschartman:mainfrom
GetsEclectic:fix/proxy-project-id
Open

fix(projects): strip ephemeral proxy prefix from project_id#13
GetsEclectic wants to merge 1 commit into
dschartman:mainfrom
GetsEclectic:fix/proxy-project-id

Conversation

@GetsEclectic

Copy link
Copy Markdown

Problem (write-blocking)

In a sandbox whose git remotes are rewritten by an HTTP proxy to http://local_proxy@127.0.0.1:<port>/git/<owner>/<repo>, the <port> is ephemeral — a new port each session. _extract_project_id_from_git_remote keeps everything after the scheme, so the port lands in the project_id. Issues created in one session become unresolvable in the next, and every trc update/close/comment aborts with:

Cannot find project path for local_proxy@127.0.0.1:37849/git/<owner>/<repo>

(Hit in practice running trc inside Anthropic's Claude-on-the-web cloud sandbox, whose egress proxy rewrites every git remote this way.)

Root cause

_extract_project_id_from_git_remote (trace_core/projects.py) strips the URL scheme and .git suffix but otherwise returns the remainder verbatim, so the ephemeral local_proxy@<host>:<port>/git/ prefix becomes part of the project identity. The canonical JSONL is unaffected (project_id is dropped on export); only the per-machine SQLite-to-project-path mapping breaks.

Fix

After scheme stripping, detect the proxy signature and reduce it to <owner>/<repo>:

proxy = re.match(r"^local_proxy@[^/]+/git/(.+)$", url)
if proxy:
    url = proxy.group(1)

Anchored on the literal local_proxy@ userinfo so it cannot touch a real-world remote. Ports 37849 and 38291 both normalize to <owner>/<repo>; https://github.com/... and git@github.com:... remotes are unchanged.

Tests

tests/test_proxy_project_id.py:

  1. Two proxy URLs differing only in port normalize to the same stable id.
  2. Ordinary https / ssh GitHub remotes are unchanged.

In a sandbox whose git remotes are rewritten by an HTTP proxy to
local_proxy@127.0.0.1:<port>/git/<owner>/<repo>, the port is ephemeral
(new each session) and leaked into the project_id, so issues created in
one session became unresolvable in the next and every write-path command
aborted with "Cannot find project path". Normalize by stripping the
local_proxy@<host>:<port>/git/ prefix to a stable <owner>/<repo>.

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants