{"record":{"id":"880b86dfbb2fb949","repo":"microsoft/semantic-kernel","slug":"request-failed-nameof-getissuedetailasync","errorCode":null,"errorMessage":"Request failed: {nameof(GetIssueDetailAsync)}","messagePattern":"Request failed: (.+?)","errorType":"exception","errorClass":"InvalidDataException","httpStatus":null,"severity":"error","filePath":"dotnet/samples/LearnResources/Plugins/GitHub/GitHubPlugin.cs","lineNumber":68,"sourceCode":"        path = BuildQuery(path, \"assignee\", assignee);\n        path = BuildQuery(path, \"labels\", label);\n        path = BuildQuery(path, \"per_page\", maxResults?.ToString() ?? string.Empty);\n\n        JsonDocument response = await MakeRequestAsync(client, path);\n\n        return response.Deserialize<GitHubModels.Issue[]>() ?? throw new InvalidDataException($\"Request failed: {nameof(GetIssuesAsync)}\");\n    }\n\n    [KernelFunction]\n    public async Task<GitHubModels.IssueDetail> GetIssueDetailAsync(string organization, string repo, int issueId)\n    {\n        using HttpClient client = this.CreateClient();\n\n        string path = $\"/repos/{organization}/{repo}/issues/{issueId}\";\n\n        JsonDocument response = await MakeRequestAsync(client, path);\n\n        return response.Deserialize<GitHubModels.IssueDetail>() ?? throw new InvalidDataException($\"Request failed: {nameof(GetIssueDetailAsync)}\");\n    }\n\n    private HttpClient CreateClient()\n    {\n        HttpClient client = new()\n        {\n            BaseAddress = new Uri(settings.BaseUrl)\n        };\n\n        client.DefaultRequestHeaders.Clear();\n        client.DefaultRequestHeaders.Add(\"User-Agent\", \"request\");\n        client.DefaultRequestHeaders.Add(\"Accept\", \"application/vnd.github+json\");\n        client.DefaultRequestHeaders.Add(\"Authorization\", $\"Bearer {settings.Token}\");\n        client.DefaultRequestHeaders.Add(\"X-GitHub-Api-Version\", \"2022-11-28\");\n\n        return client;\n    }\n","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/dotnet/samples/LearnResources/Plugins/GitHub/GitHubPlugin.cs#L50-L86","documentation":"An InvalidDataException thrown by GetIssueDetailAsync when the /repos/{org}/{repo}/issues/{id} response deserializes to a null GitHubModels.IssueDetail. Indicates the body did not map to the expected issue-detail object.","triggerScenarios":"Calling GetIssueDetailAsync(org, repo, issueId) where the endpoint returns a body that yields null on deserialization (404 error JSON, empty body, schema mismatch).","commonSituations":"Nonexistent issueId (GitHub returns a JSON error object); token without access; API schema drift; issueId is a PR number returning a different shape.","solutions":["Verify the issueId exists in org/repo and is accessible with the configured token.","Inspect the raw response to distinguish a 404 error body from a real IssueDetail payload.","Ensure MakeRequestAsync surfaces non-2xx status as exceptions before deserialization."],"exampleFix":"// before\nreturn response.Deserialize<GitHubModels.IssueDetail>() ?? throw new InvalidDataException($\"Request failed: {nameof(GetIssueDetailAsync)}\");\n// after\nvar detail = response.Deserialize<GitHubModels.IssueDetail>();\nif (detail is null) throw new InvalidDataException($\"{nameof(GetIssueDetailAsync)}: issue {issueId} in {organization}/{repo} not found or unexpected body.\");\nreturn detail;","handlingStrategy":"validation","validationCode":"if (issueId <= 0) throw new ArgumentOutOfRangeException(nameof(issueId));\nif (string.IsNullOrWhiteSpace(organization) || string.IsNullOrWhiteSpace(repo)) throw new ArgumentException(\"org/repo required\");","typeGuard":"bool IsValidIssueId(int id) => id > 0;","tryCatchPattern":"try { return await plugin.GetIssueDetailAsync(org, repo, issueId); }\ncatch (InvalidDataException ex) when (ex.Message.Contains(nameof(GitHubPlugin.GetIssueDetailAsync))) { /* verify issueId exists and token access */ }","preventionTips":["Validate issueId is a positive integer.","Ensure the HTTP layer surfaces 404 before deserialization.","Confirm token scopes for the target repository."],"tags":["github","plugin","deserialization","network"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}