Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Web: fix git blame for files that have /stream/ in their path#64230

Merged
camdencheek merged 2 commits intomainfrom
cc/fix-git-blame-stream
Aug 2, 2024
Merged

Web: fix git blame for files that have /stream/ in their path#64230
camdencheek merged 2 commits intomainfrom
cc/fix-git-blame-stream

Conversation

@camdencheek
Copy link
Member

@camdencheek camdencheek commented Aug 2, 2024

The URL path for streaming blame is ambiguous when the file path contains /stream/. The pattern looks like /blame/<repo_name>@<revision>/stream/file/path.txt. However, if the file contains /stream/, the revision is matched greedily up until the last stream, so we end up with a revision that looks like 81af3g/stream/my/path, which is in invalid revision that results in a 404.

This makes the URL pattern unambiguous by adding a /-/ element after the revision, which is not allowed in a revision name and acts as a path separator. So now, the pattern looks like /blame/<repo_name>@<revision>/-/stream/file/path.txt.

Note, this is a public-facing breaking change, but I don't think it really matters since I don't expect any customers use our streaming blame API

Fixes SRCH-738

Test plan

Tested that blame requests do not fail for files that contain /stream/

Changelog

  • Fixed an issue where blame view would error when the file contains the path element /stream/

@cla-bot cla-bot bot added the cla-signed label Aug 2, 2024
method: 'GET',
headers: {
'X-Requested-With': 'Sourcegraph',
...window.context.xhrHeaders,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated drive-by: we're already adding X-Requested-With, so this should be okay, but we should prefer to use the xhr headers sent by the backend.

@camdencheek camdencheek requested a review from a team August 2, 2024 00:22
Copy link
Contributor

@vovakulikov vovakulikov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like that path as a URL never has a state where there is no problem with it. LGTM

@camdencheek camdencheek merged commit a148d8a into main Aug 2, 2024
@camdencheek camdencheek deleted the cc/fix-git-blame-stream branch August 2, 2024 20:11
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants