Repository navigation
fix(stream): map upstream Subsonic error envelopes to HTTP errors - #286
Merged
Merged
Conversation
Navidrome answers a stale/missing track ID on /rest/stream with HTTP 200 + <error code="70"/>. The hub relayed that as a 200 audio response and logged a successful transfer. - routes/upstream-envelope.ts: detect envelope by content-type, parse code; 70 -> 404, anything else -> 502. Never echoes upstream text. - /rest/stream: reject envelopes and non-2xx peer responses (416 still passes through) before writing headers; record the failure in stream_operations. - /rest/download: same check for single tracks; album ZIPs skip the entry instead of writing XML as audio. - /federation/stream/:id: return 404/502 instead of relaying the envelope, no kind='proxy' row. FEDERATION_API_VERSION 7 -> 8 (backward-compatible both ways; floor unchanged). closes #285 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CNTqdCoTsmaZ6cqH1x5VRn
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #285
Problem
Navidrome answers a stale or missing track ID on
/rest/streamwith HTTP 200 and<error code="70"/>. The hub sent that XML to clients as a successful audio response and logged the transfer as a success.Fix
hub/src/routes/upstream-envelope.ts(new): detects a Subsonic error envelope by content-type (application/xml,text/xml,application/json) and reads it, capped at 64 KB. Code 70 maps to404, anything else to502. It never echoes upstream text back to the client./rest/stream: checks for an envelope before writing headers and records the failure instream_operations. Non-2xx peer responses now map to 404 or 502 and are logged as failures too;416still passes through./rest/download: same check for single tracks. Album ZIPs skip the broken entry instead of saving XML as an audio file./federation/stream/:id: returns404/502JSON instead of relaying the envelope, and records nokind='proxy'row.FEDERATION_API_VERSION7 → 8. Works with older hubs in both directions: a v8 caller still recognizes an envelope relayed by a v5–v7 peer, and a pre-v8 caller gets a real HTTP error. The minimum version stays at 5.federation-api.mdendpoint row and changelog; new row inpitfalls.md.Tests
stream.test.ts:upstream-envelope.test.ts: unit tests for content-type detection, parsing and reading.pnpm verifypasses with no lint output.pnpm test:federationpasses (84 compat tests plus all federation assertions).Follow-up
🤖 Generated with Claude Code
https://claude.ai/code/session_01CNTqdCoTsmaZ6cqH1x5VRn