Skip to content

cargo search doesn't follow redirects #15592

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
gtirloni opened this issue May 24, 2025 · 1 comment · May be fixed by #15593
Open

cargo search doesn't follow redirects #15592

gtirloni opened this issue May 24, 2025 · 1 comment · May be fixed by #15593
Labels
C-bug Category: bug S-triage Status: This issue is waiting on initial triage.

Comments

@gtirloni
Copy link

Problem

If a registry is redirecting the request to a different location, cargo search will fail with the following error (trimmed):

error: failed to retrieve search results from the registry at https://example.com/my_repo

Caused by:
  failed to get a 200 OK response, got 302
  headers:
  	HTTP/2 302
  	location: https://example.org/some_path/api/v1/crates?q=log&per_page=10
  	
  body:
  <html>
  <head><title>302 Found</title></head>
  <body>
  <center><h1>302 Found</h1></center>
  </body>
  </html>

Steps

  1. setup a registry that redirects
  2. cargo search --index 'sparse+https://example.com/my_repo' some_package

Possible Solution(s)

Follow redirects

Notes

No response

Version

cargo 1.87.0 (Homebrew)
release: 1.87.0
host: aarch64-apple-darwin
libgit2: 1.9.0 (sys:0.20.0 system)
libcurl: 8.7.1 (sys:0.4.80+curl-8.12.1 system ssl:(SecureTransport) LibreSSL/3.3.6)
os: Mac OS 15.5.0 [64-bit]
@gtirloni gtirloni added C-bug Category: bug S-triage Status: This issue is waiting on initial triage. labels May 24, 2025
gtirloni added a commit to gtirloni/cargo that referenced this issue May 24, 2025
@gtirloni gtirloni linked a pull request May 24, 2025 that will close this issue
@weihanglo
Copy link
Member

Possible Solution(s)

Follow redirects

Note that the change in #15593 not only affects cargo search but also other registry related commands. I wonder if there is any security implication. That said, yes, when downloading crate index and tarballs, Cargo already follows redirections.

@0xPoe, any thought?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug S-triage Status: This issue is waiting on initial triage.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants