uv/crates/cache-key
Jos van de Wolfshaar 3103180ce5
Avoid cache invalidation on credentials renewal (#3010)
# Avoid cache invalidation on credentials renewal

Addresses

- https://github.com/astral-sh/uv/issues/3009#issue-2239221126

## Summary

Some private package registries (e.g. AWS CodeArtifact) use short-lived
credentials. Since they are short-lived, the exact URL that is assigned
to `UV_INDEX_URL` changes frequently and with that the cache key /
hashes of these URLs. This causes the cache to be missed on token
renewal.

This PR attempts to fix this by hashing URLs for cache keys without
their user credentials.

## Test Plan

I added a test that validates that:
1. Changing user credentials returns the same hash
2. Setting no user credentials yields the same as some user credentials

## Question
I'm not sure if we should also change the `hash` implementation of
`CanonicalUrl` / `RepositoryUrl`. They also run `.hash` within.

PS. this is the first time I'm writing `rust` so if I'm wasting your
precious time, let me know and I'll try to up my skills before I ask
again. Anyway, I figured it's good to get this issue on your radar :)
2024-04-13 23:38:24 +00:00
..
src Avoid cache invalidation on credentials renewal (#3010) 2024-04-13 23:38:24 +00:00
Cargo.toml Split puffin-cache into Puffin-specific and generic utilities (#728) 2023-12-25 14:38:56 +00:00