{"record":{"id":"d990060361bc40d6","repo":"Jackett/Jackett","slug":"missing-api-key-d99006","errorCode":null,"errorMessage":"Missing API Key.","messagePattern":"Missing API Key\\.","errorType":"validation","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/Jackett.Common/Indexers/Definitions/MTeamTp.cs","lineNumber":128,"sourceCode":"            caps.Categories.AddCategoryMapping(432, TorznabCatType.XXX, \"AV(無碼)/Blu-Ray Uncensored\");\n            caps.Categories.AddCategoryMapping(436, TorznabCatType.XXX, \"AV(網站)/0Day\");\n            caps.Categories.AddCategoryMapping(440, TorznabCatType.XXX, \"AV(Gay)/HD\");\n            caps.Categories.AddCategoryMapping(425, TorznabCatType.XXX, \"IV(寫真影集)/Video Collection\");\n            caps.Categories.AddCategoryMapping(433, TorznabCatType.XXXImageSet, \"IV(寫真圖集)/Picture Collection\");\n            caps.Categories.AddCategoryMapping(411, TorznabCatType.XXX, \"H-Game(遊戲)\");\n            caps.Categories.AddCategoryMapping(412, TorznabCatType.XXX, \"H-Anime(動畫)\");\n            caps.Categories.AddCategoryMapping(413, TorznabCatType.XXX, \"H-Comic(漫畫)\");\n\n            return caps;\n        }\n\n        public override async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)\n        {\n            LoadValuesFromJson(configJson);\n\n            if (configData.ApiKey.Value.IsNullOrWhiteSpace())\n            {\n                throw new Exception(\"Missing API Key.\");\n            }\n\n            var releases = await PerformQuery(new TorznabQuery());\n\n            await ConfigureIfOK(string.Empty, releases.Any(),\n                                () => throw new Exception(\"Could not find releases.\"));\n\n            return IndexerConfigurationStatus.Completed;\n        }\n\n        public override async Task<byte[]> Download(Uri link)\n        {\n            var response = await RequestWithCookiesAsync(\n                link.ToString(),\n                method: RequestType.POST,\n                headers: new Dictionary<string, string>\n                {\n                    { \"Accept\", \"application/json\" },","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/Jackett/Jackett/blob/adff1941476d8057a430cf55360356c1d23e971e/src/Jackett.Common/Indexers/Definitions/MTeamTp.cs#L110-L146","documentation":"Thrown by MTeamTp.ApplyConfiguration when configData.ApiKey.Value is null, empty, or whitespace. M-Team's API authenticates exclusively via the x-api-key request header (no username/password login), so the indexer refuses to proceed with configuration if that single field is unset. This is a hard validation guard before any network call is made.","triggerScenarios":"Calling ApplyConfiguration with a configJson whose ApiKey property is missing, empty, or contains only whitespace. Occurs when a user adds the M-Team indexer but leaves the API Key field blank, or when the JSON payload is malformed/truncated so the ApiKey value doesn't deserialize.","commonSituations":"User left the API Key textbox empty in the Jackett UI; the API key was copy-pasted with stray whitespace or quotes; the configuration JSON was hand-edited and the key omitted; migrating configs between instances and the key field didn't carry over.","solutions":["Open the M-Team indexer configuration in Jackett and paste a valid API key into the ApiKey field.","Generate a fresh API key from the M-Team user settings page (the key must have API access enabled).","Ensure the key has no leading/trailing whitespace — trim it before saving.","Confirm the key works by testing it against the M-Team API with curl before reconfiguring."],"exampleFix":"// before\nif (configData.ApiKey.Value.IsNullOrWhiteSpace())\n{\n    throw new Exception(\"Missing API Key.\");\n}\n\n// after — validate with a clearer, actionable message\nvar key = configData.ApiKey.Value?.Trim();\nif (key.IsNullOrWhiteSpace())\n{\n    throw new ExceptionWithConfigData(\n        \"API Key is required. Generate one from M-Team → Settings → API.\", configData);\n}","handlingStrategy":"validation","validationCode":"// Validate before calling ApplyConfiguration\nvar key = configData?.ApiKey?.Value?.Trim();\nif (string.IsNullOrEmpty(key))\n    return IndexerConfigurationStatus.RequiresTesting; // or surface to UI without throwing","typeGuard":"bool HasApiKey(IConfigurationData config) =>\n    !string.IsNullOrWhiteSpace(config?.ApiKey?.Value);","tryCatchPattern":null,"preventionTips":["Trim the API key on input to reject whitespace-only values.","Add a UI-level required-field validator for the ApiKey before submission.","Document where to generate the key (M-Team → Settings → API) in the indexer description."],"tags":["validation","config","api-key","mteam","setup"],"backgroundTag":null,"analyzedSha":"adff1941476d8057a430cf55360356c1d23e971e","analyzedAt":"2026-08-13T15:06:32.872Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}