Skip to content

Remove "non-canonical downloads" feature #7341

@Turbo87

Description

@Turbo87

tl;dr

  • we want to improve the reliability and performance of crate downloads
  • "non-canonical downloads" are blocking these plans
  • cargo users are unaffected and only very few custom scripts are currently relying on this

What are "non-canonical downloads"?

The "non-canonical downloads" feature allows people to download the serde_derive crate from https://crates.io/api/v1/crates/serde_derive/1.0.189/download, but also from https://crates.io/api/v1/crates/serde-derive/1.0.189/download, where the underscore was replaced with a hyphen. The same also works vice versa, if the crate name uses hyphens and the download URL uses underscores instead, and it even works with any other combinations.

Why remove it?

Such non-canonical download requests require our backend to perform a database lookup to figure out the canonical crate name. The canonical crate name is then used to construct a download URL and the client is HTTP-redirected to the URL.

While we are using caching to address some of the performance concerns, having all download requests go through our backend servers has started to become problematic and at the current rate of growth will not become any easier in the future.

Having to support "non-canonical downloads" however prevents us from using CDNs for all of the download requests, so if we can remove support for these requests, we can significantly improve the performance and reliability of crate downloads.

Who is using "non-canonical downloads"?

cargo always uses the canonical crate name to construct such download URLs, so if support was removed for this on the crates.io side then cargo should still work exactly the same as before.

Looking at the crates.io request logs, the following user-agents are currently relying on non-canonical downloads working:

  • cargo-binstall/1.1.2
  • Faraday v0.17.6
  • Go-http-client/2.0
  • GNU Guile
  • python-requests/2.31.0

Three of these are just generic HTTP client libraries. GNU Guile is apparently a programming language, so most likely this is also a generic user-agent from a custom user program.

cargo-binstall refers to https://github.com/cargo-bins/cargo-binstall. From the low number of non-canonical download requests it is unclear at this point how and why they might be affected, but we will let the maintainers know about this issue and our plans.

What is the plan?

  1. Announce the removal of support for non-canonical downloads on the main Rust blog.
  2. Wait one month.
  3. Disable support for non-canonical downloads and return a migration error message instead.
  4. Wait one month.
  5. Return a regular 404 error instead of the migration error message, allowing us to get rid of (parts of) the database query.

Note that we will still need the database query for download counting purposes for now. We have plans to remove this requirement as well, but those efforts are blocked by us needing to support non-canonical downloads.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-backend ⚙️C-tracking-issueCategory: A tracking issue for an RFC, an unstable feature, or an issue made of many parts

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions