downloads broken in production: uuid.Parse rejects keys with leading slash (regression from #50 fix) #64

Closed
opened 2026-05-27 13:21:39 +02:00 by heiko · 1 comment
Owner

Symptom

All downloads return 404. Server log on pu.schlittermann.de:

Mai 27 13:12:51 pu once-server[26931]: invalid key in path "/dl/fe27dd79-be34-4bf4-bf99-d7b452138273": invalid key format: invalid UUID length: 37
Mai 27 13:13:47 pu once-server[26931]: invalid key in path "/dl/b96e57c5-25d6-41d0-b453-405f18e2732e": invalid key format: invalid UUID length: 37
Mai 27 13:15:33 pu once-server[26931]: invalid key in path "/dl/a0908a54-4b67-4db7-aca5-b131444e04ba": invalid key format: invalid UUID length: 37

Root cause

DownloadPrefix = "dl/" but path.Join("/", "dl/") strips the trailing slash, giving prefix "/dl". Then in parseKey():

TrimPrefix("/dl/uuid", "/dl") -> "/uuid"  (37 chars, leading slash retained)
uuid.Parse("/uuid")           -> invalid UUID length: 37

Fix

Already committed in 84d9039505785e1d72d30514df2238cefe22321b: the second key = strings.TrimPrefix(key, "/") in parseKey() strips the leading slash before UUID validation. Regression test "prefix without trailing slash (path.Join regression)" added in key_test.go.

The binary on pu was deployed 2026-05-24 and predates this commit. Rebuild and redeploy to fix.

Uploaded files

Files in /var/lib/once/store/heiko/ are intact — all download attempts were rejected before reaching the store.

## Symptom All downloads return 404. Server log on pu.schlittermann.de: ``` Mai 27 13:12:51 pu once-server[26931]: invalid key in path "/dl/fe27dd79-be34-4bf4-bf99-d7b452138273": invalid key format: invalid UUID length: 37 Mai 27 13:13:47 pu once-server[26931]: invalid key in path "/dl/b96e57c5-25d6-41d0-b453-405f18e2732e": invalid key format: invalid UUID length: 37 Mai 27 13:15:33 pu once-server[26931]: invalid key in path "/dl/a0908a54-4b67-4db7-aca5-b131444e04ba": invalid key format: invalid UUID length: 37 ``` ## Root cause `DownloadPrefix = "dl/"` but `path.Join("/", "dl/")` strips the trailing slash, giving prefix `"/dl"`. Then in `parseKey()`: ``` TrimPrefix("/dl/uuid", "/dl") -> "/uuid" (37 chars, leading slash retained) uuid.Parse("/uuid") -> invalid UUID length: 37 ``` ## Fix Already committed in `84d9039505785e1d72d30514df2238cefe22321b`: the second `key = strings.TrimPrefix(key, "/")` in `parseKey()` strips the leading slash before UUID validation. Regression test `"prefix without trailing slash (path.Join regression)"` added in `key_test.go`. The binary on `pu` was deployed 2026-05-24 and predates this commit. **Rebuild and redeploy to fix.** ## Uploaded files Files in `/var/lib/once/store/heiko/` are intact — all download attempts were rejected before reaching the store.
Author
Owner

Fixed in commit 84d9039 (already on master before this issue was filed — spotted it in the production logs).

The fix strips the leading slash from the extracted key before UUID validation:

key = strings.TrimPrefix(key, "/")

Regression test "prefix without trailing slash (path.Join regression)" added in key_test.go.

Still needs a package rebuild and apt upgrade on pu to go live.

Fixed in commit `84d9039` (already on master before this issue was filed — spotted it in the production logs). The fix strips the leading slash from the extracted key before UUID validation: ```go key = strings.TrimPrefix(key, "/") ``` Regression test `"prefix without trailing slash (path.Join regression)"` added in `key_test.go`. Still needs a package rebuild and `apt upgrade` on `pu` to go live.
heiko closed this issue 2026-05-27 13:28:01 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
IUS/once#64
No description provided.