(ctx context.Context, client *github.Client, deps ToolDependencies, owner string, repo string, issueNumber int, pagination PaginationParams)
| 837 | } |
| 838 | |
| 839 | func GetSubIssues(ctx context.Context, client *github.Client, deps ToolDependencies, owner string, repo string, issueNumber int, pagination PaginationParams) (*mcp.CallToolResult, error) { |
| 840 | cache, err := deps.GetRepoAccessCache(ctx) |
| 841 | if err != nil { |
| 842 | return nil, fmt.Errorf("failed to get repo access cache: %w", err) |
| 843 | } |
| 844 | featureFlags := deps.GetFlags(ctx) |
| 845 | |
| 846 | opts := &github.ListOptions{ |
| 847 | Page: pagination.Page, |
| 848 | PerPage: pagination.PerPage, |
| 849 | } |
| 850 | |
| 851 | subIssues, resp, err := client.SubIssue.ListByIssue(ctx, owner, repo, int64(issueNumber), opts) |
| 852 | if err != nil { |
| 853 | return ghErrors.NewGitHubAPIErrorResponse(ctx, |
| 854 | "failed to list sub-issues", |
| 855 | resp, |
| 856 | err, |
| 857 | ), nil |
| 858 | } |
| 859 | |
| 860 | defer func() { _ = resp.Body.Close() }() |
| 861 | |
| 862 | if resp.StatusCode != http.StatusOK { |
| 863 | body, err := io.ReadAll(resp.Body) |
| 864 | if err != nil { |
| 865 | return nil, fmt.Errorf("failed to read response body: %w", err) |
| 866 | } |
| 867 | return ghErrors.NewGitHubAPIStatusErrorResponse(ctx, "failed to list sub-issues", resp, body), nil |
| 868 | } |
| 869 | |
| 870 | if featureFlags.LockdownMode { |
| 871 | if cache == nil { |
| 872 | return nil, fmt.Errorf("lockdown cache is not configured") |
| 873 | } |
| 874 | filteredSubIssues := make([]*github.SubIssue, 0, len(subIssues)) |
| 875 | for _, subIssue := range subIssues { |
| 876 | user := subIssue.User |
| 877 | if user == nil { |
| 878 | continue |
| 879 | } |
| 880 | login := user.GetLogin() |
| 881 | if login == "" { |
| 882 | continue |
| 883 | } |
| 884 | isSafeContent, err := cache.IsSafeContent(ctx, login, owner, repo) |
| 885 | if err != nil { |
| 886 | return utils.NewToolResultError(fmt.Sprintf("failed to check lockdown mode: %v", err)), nil |
| 887 | } |
| 888 | if isSafeContent { |
| 889 | filteredSubIssues = append(filteredSubIssues, subIssue) |
| 890 | } |
| 891 | } |
| 892 | subIssues = filteredSubIssues |
| 893 | } |
| 894 | |
| 895 | r, err := json.Marshal(subIssues) |
| 896 | if err != nil { |
no test coverage detected