modrinth / labrinth

Our Rust-based backend utilizing the actix-web framework to serve Modrinth's API.

Home Page:https://modrinth.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

POST `/version_files/update` still requires lowercase hashes

mohkamfer opened this issue · comments

Describe the bug

I'm still getting this same issue. It was reported in #369 (she's not fine) and was said to be fixed:

fixed by #374
Originally posted by @Geometrically in #369 (comment)

Here are two requests that demonstrate the issue, tested on Postman:

curl --location 'https://api.modrinth.com/v2/version_files/update' \
--header 'Content-Type: application/json' \
--data '{
  "loaders": ["fabric"],
  "game_versions": ["1.19.2"],
  "algorithm": "sha1",
  "hashes": ["5F978F794395C44F1F4AA5C7D28B5D74113A605A"]
}'

this request returns nothing, while this one works:

curl --location 'https://api.modrinth.com/v2/version_files/update' \
--header 'Content-Type: application/json' \
--data '{
  "loaders": ["fabric"],
  "game_versions": ["1.19.2"],
  "algorithm": "sha1",
  "hashes": ["5f978f794395c44f1f4aa5c7d28b5d74113a605a"]
}'

Steps to reproduce

  1. Get a sample hash to test the endpoint with. The following hash is for the mod AdvancedChatCore: 5F978F794395C44F1F4AA5C7D28B5D74113A605A
  2. Convert the hash to lowercase: 5f978f794395c44f1f4aa5c7d28b5d74113a605a
  3. Test the endpoint once with uppercase, and observe the result.
  "loaders": ["fabric"],
  "game_versions": ["1.19.2"],
  "algorithm": "sha1",
  "hashes": ["5F978F794395C44F1F4AA5C7D28B5D74113A605A"]
  1. Test the endpoint once with lowercase, and inspect the response.
  "loaders": ["fabric"],
  "game_versions": ["1.19.2"],
  "algorithm": "sha1",
  "hashes": ["5f978f794395c44f1f4aa5c7d28b5d74113a605a"]

Expected behavior

The response:

{
  "5f978f794395c44f1f4aa5c7d28b5d74113a605a": {
    /* ... */
  }
}

should be returned regardless of the case of the hash, as most tools, libraries, and frameworks calculate hashes in varying formats!

Additional context

No response