pr-comment: preserve https:// URLs in free /review base_file#120
Merged
Conversation
The free review URL builder runs the base/revision inputs through
sed 's/.*://'
intending to strip the git-ref prefix in "origin/main:openapi.yaml"
so the /review page receives just "openapi.yaml". For URL-shaped
inputs like "https://raw.githubusercontent.com/o/r/main/foo.yaml",
the same sed strips "https:" too and leaves a broken
"//raw.githubusercontent.com/..." in the base_file= parameter.
The /review page then tries to GET the broken URL, the fetch fails,
and the access-denied screen renders — which misreports the cause
as authorization ("@owner doesn't have access to o/r") even though
the real problem is the malformed URL the page received.
Surfaced via oasdiff-test/test#59, whose workflow uses a URL-shaped
base. (Workflows using the git-ref form are unaffected — that path
still works correctly.)
Fix: wrap the strip in a case-branch helper that passes http:// and
https:// inputs through unchanged, only running the sed on inputs
that look like a git ref.
Two regression tests cover both branches:
- pr_comment_free_review_url_preserves_https_base
- pr_comment_free_review_url_strips_git_ref_prefix
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
3 tasks
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
The free review URL builder in
pr-comment/entrypoint.shruns thebaseandrevisioninputs through:The sed is meant to strip the git-ref prefix in inputs like
origin/main:openapi.yamlso the/reviewpage receives justopenapi.yaml. But for inputs that are URLs (https://raw.githubusercontent.com/o/r/main/foo.yaml), the same sed stripshttps:and leaves a broken//raw.githubusercontent.com/...in thebase_file=query parameter of the emitted::notice::URL.The
/reviewpage then tries to GET the broken URL as the base spec, the fetch fails, and the access-denied screen renders — misreporting the cause as authorization ("@owner doesn't have access to o/r") even though the real problem is the malformed URL the page received from the action.Reproducer
oasdiff-test/test's workflow uses URL-shaped base inputs:So every action run there emits a broken
::notice::link. Workflows that use the git-ref form (origin/main:foo.yaml) — the more common shape — are unaffected.Fix
A case-branch helper that:
http://orhttps://— pass through unchangedTests
Two new regression tests, both stubbing
oasdiffto a no-changes spec so the entrypoint emits the::notice::and exits:pr_comment_free_review_url_preserves_https_base— base = URL; verifies the emitted notice containsbase_file=https%3A%2F%2Fraw.githubusercontent.com...(full URL encoded), and explicitly fails with a clear message if it finds the brokenbase_file=%2F%2Fraw...formpr_comment_free_review_url_strips_git_ref_prefix— base =origin/main:multi-file/openapi.yaml; verifies the prefix is still stripped to just the pathIf the case branch is ever reverted, both tests fail with specific pointers at the cause.
Test plan
bash -nand YAML parse cleanbase_file=query params/reviewlink resolves instead of access-denyingCo-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com
Generated with Claude Code