Skip to content

Comments

Support GitHub Gist URLs via HTTP redirects in uv run#16451

Merged
charliermarsh merged 1 commit intoastral-sh:mainfrom
twilligon:gist-redirect
Oct 29, 2025
Merged

Support GitHub Gist URLs via HTTP redirects in uv run#16451
charliermarsh merged 1 commit intoastral-sh:mainfrom
twilligon:gist-redirect

Conversation

@twilligon
Copy link
Contributor

Summary

Extend the existing GitHub Gist URL support from #15058 to handle URLs that redirect to Gists.

reqwest already handled generic URL redirects for us (note this redirects directly to the .py on gist.githubusercontent.com):

~/git/uv $ uv run https://httpbin.org/redirect-to?url=https://gist.githubusercontent.com/twilligon/4d878a4d9550a4f1df258cde1f058699/raw/c28a4bf0cb6bb9e670cb47c95d28971ffac163e5/hello.py
hello world!

But running a URL that redirected to a Gist's "main page" (a bit.ly link leading to a Gist, etc.) did not:

~/git/uv $ uv run https://httpbin.org/redirect-to?url=https://gist.github.com/twilligon/4d878a4d9550a4f1df258cde1f058699
  File "/tmp/scriptNodt3Q.py", line 87
    <title>hello.py · GitHub</title>

But if we have reqwest follow redirects before resolve_gist_url, we can handle this fine:

~/git/uv $ target/debug/uv run https://httpbin.org/redirect-to?url=https://gist.github.com/twilligon/4d878a4d9550a4f1df258cde1f058699
hello world!

Test Plan

I'd write an automated test but that'd require network access since wiremock doesn't seem to support mocking specific hostnames like gist.github.com. As manual tests go, I basically did the above, testing with several redirectors to both generic and Gist URLs.

@twilligon twilligon changed the title Support GitHub Gist URLs via HTTP redirects in uv run Support GitHub Gist URLs via HTTP redirects in uv run Oct 26, 2025
Copy link
Member

@charliermarsh charliermarsh left a comment

Choose a reason for hiding this comment

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

That seems reasonable.

@charliermarsh charliermarsh merged commit db1d34e into astral-sh:main Oct 29, 2025
100 checks passed
@twilligon
Copy link
Contributor Author

Thanks!

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