{"record":{"id":"257680a0725999f2","repo":"microsoft/semantic-kernel","slug":"request-failed-nameof-getissuesasync","errorCode":null,"errorMessage":"Request failed: {nameof(GetIssuesAsync)}","messagePattern":"Request failed: (.+?)","errorType":"exception","errorClass":"InvalidDataException","httpStatus":null,"severity":"error","filePath":"dotnet/samples/LearnResources/Plugins/GitHub/GitHubPlugin.cs","lineNumber":56,"sourceCode":"        string repo,\n        [Description(\"default count is 30\")]\n        int? maxResults = null,\n        [Description(\"open, closed, or all\")]\n        string state = \"\",\n        string label = \"\",\n        string assignee = \"\")\n    {\n        using HttpClient client = this.CreateClient();\n\n        string path = $\"/repos/{organization}/{repo}/issues?\";\n        path = BuildQuery(path, \"state\", state);\n        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        {","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/dotnet/samples/LearnResources/Plugins/GitHub/GitHubPlugin.cs#L38-L74","documentation":"An InvalidDataException thrown by GetIssuesAsync when the /repos/{org}/{repo}/issues response deserializes to a null Issue[] (or non-array body). The issues endpoint returns a JSON array; a null result means the body was not a deserializable array of issues.","triggerScenarios":"Calling GetIssuesAsync when the issues endpoint returns a body that does not deserialize into GitHubModels.Issue[] (error object instead of array, empty, or schema mismatch).","commonSituations":"Bad org/repo or no access producing a JSON error object (not an array); invalid state/label/assignee query params; token scopes insufficient; API schema change.","solutions":["Confirm org/repo and that the token can read issues.","Validate state/label/assignee parameters are within accepted values (open/closed/all).","Inspect the raw response to ensure it is a JSON array before array deserialization.","Make MakeRequestAsync throw on non-2xx so error bodies never reach the deserializer."],"exampleFix":"// before\nreturn response.Deserialize<GitHubModels.Issue[]>() ?? throw new InvalidDataException($\"Request failed: {nameof(GetIssuesAsync)}\");\n// after\nvar issues = response.Deserialize<GitHubModels.Issue[]>();\nif (issues is null) throw new InvalidDataException($\"{nameof(GetIssuesAsync)}: expected issue array for {organization}/{repo}, got: {response.RootElement.GetRawText()}\");\nreturn issues;","handlingStrategy":"validation","validationCode":"var allowed = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { \"\", \"open\", \"closed\", \"all\" };\nif (!allowed.Contains(state)) throw new ArgumentOutOfRangeException(nameof(state));\nif (string.IsNullOrWhiteSpace(organization) || string.IsNullOrWhiteSpace(repo)) throw new ArgumentException(\"org/repo required\");","typeGuard":"bool IsValidIssueState(string s) => s is \"\" or \"open\" or \"closed\" or \"all\";","tryCatchPattern":"try { return await plugin.GetIssuesAsync(org, repo, maxResults, state, label, assignee); }\ncatch (InvalidDataException ex) when (ex.Message.Contains(nameof(GitHubPlugin.GetIssuesAsync))) { /* verify params, token, and that body is a JSON array */ }","preventionTips":["Constrain state to open/closed/all at the call site.","Have the HTTP layer throw on non-2xx to avoid deserializing error objects as arrays.","Log raw body when array deserialization yields null."],"tags":["github","plugin","deserialization","network"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}