Commit aee5b9d
fix: don't sign media links with an empty cid (#993)
## Problem
BURKO stems downloads were failing (incident 2026-07-16, ~20:22 UTC).
The parent track `qJ0RAXE` (1960897973) has `track_cid = null` and
`orig_file_cid = null` — an upload-v2 row whose cid backfill never ran
(`audio_upload_id` is set and the mediorum upload record is complete).
The Tracks hydrator signed whatever cid it was given, so
`/v1/tracks/{id}/download` and `/stream` 302'd to `tracks/cidstream/`
with an **empty cid** in the signed payload, which every validator node
404s. That fed the archiver a guaranteed-404 URL and also silently broke
playback for such tracks.
## Fix
- `dbv1/tracks.go`: skip building the `stream`/`download` MediaLink when
there is no cid to sign — the links are now `null` in track responses
instead of pointing at a 404.
- `v1_track_stream.go`: nil-guard before `redirectToStream` (which would
nil-deref in `tryFindWorkingUrl`); returns 404 "track audio is
unavailable". `/download` already 404s on a nil link.
- Tests: fixture tracks 100/200 get a `track_cid` (previously every
fixture signed an empty cid — `TestGetTrackDownload` was asserting the
buggy URL); new `TestGetTrackDownload_NoCid` and
`TestGetTrackStream_NoCid` cover the empty-cid → 404 behavior.
Full `go test ./api/...` passes.
## Related
- pedalboard#75 (already deployed) makes the archiver treat the parent
track as best-effort, so stems archives survive a broken parent.
- Follow-up needed: backfill `track_cid`/`orig_file_cid` for track
1960897973 from its mediorum upload record
(`1cc9774d05f78bf91272c59080246ef8`) — until then the track can't stream
or download at all (this PR just makes the failure honest).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>1 parent 8b7d6bd commit aee5b9d
5 files changed
Lines changed: 77 additions & 7 deletions
File tree
- api
- dbv1
- testdata
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
196 | 196 | | |
197 | 197 | | |
198 | 198 | | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
199 | 204 | | |
200 | | - | |
| 205 | + | |
201 | 206 | | |
202 | 207 | | |
203 | 208 | | |
| |||
210 | 215 | | |
211 | 216 | | |
212 | 217 | | |
213 | | - | |
214 | | - | |
215 | | - | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
216 | 223 | | |
217 | 224 | | |
218 | 225 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
21 | 50 | | |
22 | 51 | | |
23 | 52 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
33 | 38 | | |
34 | 39 | | |
35 | 40 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
7 | 9 | | |
8 | 10 | | |
9 | 11 | | |
| |||
21 | 23 | | |
22 | 24 | | |
23 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
24 | 53 | | |
25 | 54 | | |
26 | 55 | | |
| |||
0 commit comments