Skip to content

Refuse "", "." and ".." as path coordinates before any request - #84

Open
Rohan-Singhh wants to merge 2 commits into
prooflinedev:mainfrom
Rohan-Singhh:fix/refuse-dot-path-coordinates
Open

Rohan-Singhh wants to merge 2 commits into
prooflinedev:mainfrom
Rohan-Singhh:fix/refuse-dot-path-coordinates

Conversation

@Rohan-Singhh

@Rohan-Singhh Rohan-Singhh commented Nov 22, 2026 •

Copy link
Copy Markdown

Problem

list_pull_request_reviews, get_pull_request_review and get_deployment_review take a caller string (repository or public_key) as a URL path segment. The generated code encodes it with quote(value, safe=""), which leaves . and .. unchanged. The URL then resolves them as dot segments, so the request goes to a different endpoint:

Call Request actually sent
get_deployment_review(org, "..") GET /api/v1/organizations/{org}/reviews (the list_reviews endpoint)
get_deployment_review(org, ".") GET /api/v1/organizations/{org}/reviews/deployments
list_pull_request_reviews(org, "..", 7) GET /api/v1/organizations/{org}/reviews/7 (the get_review route, with id 7)
get_pull_request_review(org, "..", 7, 1) GET /api/v1/organizations/{org}/reviews/7/runs/1
get_deployment_review(org, "") GET /api/v1/organizations/{org}/reviews/deployments/

In each case the caller gets an API problem or an invalid-response error about some other endpoint, not an error that points at their argument. This matters when the value comes from outside, such as a CI variable or user input.

The TypeScript SDK already refuses these values. coordinate() in sdk-typescript/src/transport.ts throws for "", "." and ".." before sending anything. The Python SDK has no matching check.

Change

  • Add _coordinate(value) in proofline/client.py. It raises ValueError("A path coordinate must be nonempty and not a traversal segment.") for "", "." and "..", and otherwise returns the value unchanged.
  • Call it for repository / public_key in the three methods, in both ProoflineClient and AsyncProoflineClient.
  • ValueError follows the convention this client already uses for caller errors, for example _head_commit and the pagination limits.

Only exact dot segments are refused. Values that merely contain dots still work and stay one encoded segment: "..." is sent as .../reviews/deployments/..., and "owner/.github" as .../reviews/pr/owner%2F.github/....

Verification

Two new tests in tests/test_http.py run against the local fake server, in sync and async mode:

  • test_traversal_path_coordinates_are_refused_before_any_request covers 3 methods × 3 values × 2 modes, 18 cases in all. It checks for ValueError and that the server received no request.
  • test_dotted_path_coordinates_stay_one_encoded_segment checks that legitimate dotted values are still sent, to the exact expected path, for all three methods.

Steps to reproduce:

# The new tests fail without the fix (18 failed, 2 passed)
git checkout main -- proofline/client.py
.venv/bin/python -m pytest -q tests/test_http.py -k "traversal or dotted"

# ...and pass with it
git checkout HEAD -- proofline/client.py
.venv/bin/python -m pytest -q tests/test_http.py -k "traversal or dotted"

All of the checks from scripts/check.py pass locally: generate.py --check, contracts.py, ruff check, ruff format --check, mypy proofline scripts, and pytest (239 passed).

Proofline review

I installed Proofline on my own account and had it review this branch in a PR on my fork (Rohan-Singhh#1) before opening this one.

  • Run 1 (c641017): 1 warning, test quality. Proofline pointed out that test_dotted_path_coordinates_stay_one_encoded_segment never called list_pull_request_reviews. My change touched three methods, but the "valid dotted names still work" test only covered two, so list_pull_request_reviews could have rejected or misrouted a name like owner/.github while the tests stayed green. (review)
  • I agreed and fixed it in a9bc23b. The test now calls list_pull_request_reviews(org, "owner/.github", 7) in both modes and asserts the exact encoded path. To confirm it closes the gap, I temporarily changed _coordinate to reject any value containing a dot: the test then failed at the list_pull_request_reviews call. Then I reverted that change.
  • Run 2 (a9bc23b): no findings. (review)

Not covered

Methods generated from the contract (proofline/_generated/api/operations.py) take string path parameters as well, for example commit_sha in get_commit_deploy_verifications, and they encode the same way. That code is generated, so per the README I've left it alone. I'm happy to open an issue for it if that would help.

Related to #75, which handles a different kind of caller error. This PR doesn't overlap with it.

🤖 Generated with Claude Code

Rohan-Singhh and others added 2 commits November 23, 2026 01:14
Percent-encoding leaves "." and ".." unchanged, so the URL resolves them as dot
segments and the request reaches another endpoint: get_deployment_review(org, "..")
read list_reviews, and list_pull_request_reviews(org, "..", 7) read get_review
for id "7". An empty value produced an empty segment. The caller got an API
problem or an invalid-response error instead of a caller error.

list_pull_request_reviews, get_pull_request_review and get_deployment_review now
raise ValueError for these values in the sync and async clients, as the
TypeScript SDK's coordinate() already does, and send nothing. Values that only
contain dots, such as "..." or "owner/.github", stay one encoded segment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The dotted-coordinate test checked get_pull_request_review and
get_deployment_review but never list_pull_request_reviews, so that method
could reject or misroute a valid name such as "owner/.github" while the
tests stayed green. It now asserts the exact encoded path for all three
methods in both modes. Found by Proofline's review of this change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant