{"record":{"id":"454da000b4a88ab9","repo":"navidrome/navidrome","slug":"internal-server-error-454da0","errorCode":null,"errorMessage":"Internal Server Error","messagePattern":"Internal Server Error","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"server/subsonic/transcode.go","lineNumber":401,"sourceCode":"\ttranscodeParamsToken, err := p.String(\"transcodeParams\")\n\tif err != nil {\n\t\thttp.Error(w, \"Bad Request\", http.StatusBadRequest)\n\t\treturn nil, nil\n\t}\n\n\tif !isValidMediaType(mediaType) {\n\t\thttp.Error(w, \"Bad Request\", http.StatusBadRequest)\n\t\treturn nil, nil\n\t}\n\n\t// Fetch the media file\n\tmf, err := api.ds.MediaFile(ctx).Get(mediaID)\n\tif err != nil {\n\t\tif errors.Is(err, model.ErrNotFound) {\n\t\t\thttp.Error(w, \"Not Found\", http.StatusNotFound)\n\t\t} else {\n\t\t\tlog.Error(ctx, \"Error retrieving media file\", \"mediaID\", mediaID, err)\n\t\t\thttp.Error(w, \"Internal Server Error\", http.StatusInternalServerError)\n\t\t}\n\t\treturn nil, nil\n\t}\n\n\t// Validate the token and resolve streaming parameters\n\tstreamReq, err := api.transcodeDecision.ResolveRequestFromToken(ctx, transcodeParamsToken, mf, p.IntOr(\"offset\", 0))\n\tif err != nil {\n\t\tswitch {\n\t\tcase errors.Is(err, stream.ErrTokenInvalid), errors.Is(err, stream.ErrTokenStale):\n\t\t\tlog.Warn(ctx, \"Invalid or stale transcode token\", \"mediaID\", mediaID, err)\n\t\t\thttp.Error(w, \"Gone\", http.StatusGone)\n\t\tdefault:\n\t\t\tlog.Error(ctx, \"Error validating transcode params\", err)\n\t\t\thttp.Error(w, \"Internal Server Error\", http.StatusInternalServerError)\n\t\t}\n\t\treturn nil, nil\n\t}\n","sourceCodeStart":383,"sourceCodeEnd":419,"githubUrl":"https://github.com/navidrome/navidrome/blob/4ed7494a3293a9e9e647897ebfb9be327efd981b/server/subsonic/transcode.go#L383-L419","documentation":"GetTranscodeStream logs 'Error retrieving media file' and writes plain-text 'Internal Server Error' (HTTP 500) when api.ds.MediaFile(ctx).Get(mediaID) returns an error that is NOT model.ErrNotFound. The 404 path is reserved for missing records; any other failure (DB down, connection refused, context canceled, corruption) lands here.","triggerScenarios":"Database unavailable or restarting during a request; DB query fails (disk full, locked SQLite file, connection pool exhausted); request context canceled mid-query; schema mismatch after an incomplete upgrade.","commonSituations":"SQLite file locked by a backup process; Postgres container down; running the server while a migration is in flight; disk I/O errors on the DB volume.","solutions":["Check server logs for the accompanying 'Error retrieving media file' entry to see the underlying error","Verify the database backend is reachable and healthy (DB connection settings, service status)","For SQLite, ensure no other process holds a conflicting lock and the file is writable","Check disk space and complete any pending schema migrations, then retry"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Preflight: cheap health check of the server before batch streaming\nresp, err := http.Get(serverURL + \"/ping\")\nif err != nil || resp.StatusCode != 200 {\n    return fmt.Errorf(\"server or database unavailable: %v\", err)\n}","typeGuard":null,"tryCatchPattern":"resp, err := client.Get(url)\nif err != nil { return err }\nif resp.StatusCode == http.StatusInternalServerError {\n    // transient server/DB failure: retry with backoff\n    return retryWithBackoff(3, 2*time.Second, doStream)\n}","preventionTips":["Treat 500 during streaming as transient and retry with capped exponential backoff","Monitor server health/DB connectivity before large batch operations","Ensure backups don't hold DB locks during playback (SQLite)","Keep the server upgraded with completed migrations"],"tags":["http","internal-server-error","database","subsonic"],"backgroundTag":"database-unavailable","analyzedSha":"4ed7494a3293a9e9e647897ebfb9be327efd981b","analyzedAt":"2026-09-01T05:03:05.018Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}