{"record":{"id":"b621ab5ea58e46d2","repo":"Sonarr/Sonarr","slug":"seriesids-must-be-positive-integers-b621ab","errorCode":null,"errorMessage":"seriesIds must be positive integers","messagePattern":"seriesIds must be positive integers","errorType":"http","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"src/Sonarr.Api.V5/Episodes/RenameEpisodeController.cs","lineNumber":43,"sourceCode":"        {\n            return TypedResults.Ok(_renameEpisodeFileService.GetRenamePreviews(seriesId, seasonNumber.Value).ToResource());\n        }\n\n        return TypedResults.Ok(_renameEpisodeFileService.GetRenamePreviews(seriesId).ToResource());\n    }\n\n    [HttpGet(\"bulk\")]\n    [Produces(\"application/json\")]\n    public Results<Ok<List<RenameEpisodeResource>>, BadRequest> GetEpisodes([FromQuery] List<int> seriesIds)\n    {\n        if (seriesIds is { Count: 0 })\n        {\n            throw new BadRequestException(\"seriesIds must be provided\");\n        }\n\n        if (seriesIds.Any(seriesId => seriesId <= 0))\n        {\n            throw new BadRequestException(\"seriesIds must be positive integers\");\n        }\n\n        return TypedResults.Ok(_renameEpisodeFileService.GetRenamePreviews(seriesIds).ToResource());\n    }\n}\n","sourceCodeStart":25,"sourceCodeEnd":49,"githubUrl":"https://github.com/Sonarr/Sonarr/blob/da2284d7eaab22ed9b2ca698af690148d691e967/src/Sonarr.Api.V5/Episodes/RenameEpisodeController.cs#L25-L49","documentation":"Returned as HTTP 400 (BadRequestException) by GET /api/v5/rename/bulk when the seriesIds list contains any value less than or equal to zero. This guard runs after the empty-list check, so it only fires when the list is non-empty but includes a non-positive (invalid) id.","triggerScenarios":"GET /api/v5/rename/bulk?seriesIds=5,0 or ?seriesIds=-1,2 — any list where at least one id is <= 0.","commonSituations":"A default/uninitialized sentinel value (0 or -1) leaks into the id list. A UI multi-select includes a placeholder row. A script fails to filter out invalid ids from upstream data.","solutions":["Filter the seriesIds list to only positive integers before sending the request","Investigate the source of the 0/-1 value and fix the upstream selection logic","Add a client-side assertion that all ids are > 0"],"exampleFix":"// before\nvar qs = \"?seriesIds=\" + string.Join(\",\", rawSeriesIds);\n\n// after — strip invalid ids\nvar validIds = rawSeriesIds.Where(id => id > 0).ToList();\nif (!validIds.Any()) return;\nvar qs = \"?seriesIds=\" + string.Join(\",\", validIds);","handlingStrategy":"validation","validationCode":"if (seriesIds.Any(id => id <= 0))\n    throw new ArgumentException(\"All seriesIds must be positive integers\");\n// or filter them out: var safe = seriesIds.Where(id => id > 0).ToList();","typeGuard":"static bool AllPositive(IEnumerable<int> ids) => ids.All(id => id > 0);","tryCatchPattern":null,"preventionTips":["Filter out 0/-1 sentinel values before sending","Trace where invalid ids originate and fix the upstream selection"],"tags":["rename","http-400","validation","query-parameter","invalid-id"],"backgroundTag":null,"analyzedSha":"da2284d7eaab22ed9b2ca698af690148d691e967","analyzedAt":"2026-08-13T15:53:02.562Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}