Repository navigation
Refuse "", "." and ".." as path coordinates before any request - #1
Open
Rohan-Singhh wants to merge 2 commits into
Open
Rohan-Singhh wants to merge 2 commits into
Rohan-Singhh wants to merge 2 commits into
Conversation
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 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
list_pull_request_reviews,get_pull_request_reviewandget_deployment_reviewtake a caller string (repositoryorpublic_key) as a URL path segment. The generated code encodes it withquote(value, safe=""), which leaves.and..unchanged. The URL then resolves them as dot segments, so the request goes to a different endpoint:get_deployment_review(org, "..")GET /api/v1/organizations/{org}/reviews(thelist_reviewsendpoint)get_deployment_review(org, ".")GET /api/v1/organizations/{org}/reviews/deploymentslist_pull_request_reviews(org, "..", 7)GET /api/v1/organizations/{org}/reviews/7(theget_reviewroute, with id7)get_pull_request_review(org, "..", 7, 1)GET /api/v1/organizations/{org}/reviews/7/runs/1get_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()insdk-typescript/src/transport.tsthrows for"","."and".."before sending anything. The Python SDK has no matching check.Change
_coordinate(value)inproofline/client.py. It raisesValueError("A path coordinate must be nonempty and not a traversal segment.")for"","."and"..", and otherwise returns the value unchanged.repository/public_keyin the three methods, in bothProoflineClientandAsyncProoflineClient.ValueErrorfollows the convention this client already uses for caller errors, for example_head_commitand 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.pyrun against the local fake server, in sync and async mode:test_traversal_path_coordinates_are_refused_before_any_requestcovers 3 methods × 3 values × 2 modes, 18 cases in all. It checks forValueErrorand that the server received no request.test_dotted_path_coordinates_stay_one_encoded_segmentchecks that legitimate dotted values are still sent, to the exact expected path.Steps to reproduce:
All of the checks from
scripts/check.pypass locally:generate.py --check,contracts.py,ruff check,ruff format --check,mypy proofline scripts, andpytest(239 passed).Not covered
Methods generated from the contract (
proofline/_generated/api/operations.py) take string path parameters as well, for examplecommit_shainget_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 prooflinedev#75, which handles a different kind of caller error. This PR doesn't overlap with it.
🤖 Generated with Claude Code