Skip to content

Add field_values to search_issues results#2474

Draft
kelsey-myers wants to merge 4 commits into
github:mainfrom
kelsey-myers:kelsey/search-issues-field-values
Draft

Add field_values to search_issues results#2474
kelsey-myers wants to merge 4 commits into
github:mainfrom
kelsey-myers:kelsey/search-issues-field-values

Conversation

@kelsey-myers
Copy link
Copy Markdown

@kelsey-myers kelsey-myers commented May 13, 2026

Summary

Extends search_issues to include custom issue field values (field_values) on each result item, fetched via a single follow-up GraphQL nodes() query after the REST search.

Why

Closes github/plan-track-agentic-toolkit#119

search_issues returned no field values (priority, estimate, etc.) even when issues had them. Agents couldn't act on field data from search results without a separate lookup per issue.

What changed

search_issues previously used the REST search API and returned results as-is. A full GraphQL rewrite would have changed the pagination model (cursor-based instead of page-based), which would be a breaking change for existing callers. Instead, this keeps REST for the search itself and adds a single follow-up nodes(ids:[...]) GraphQL query per page to fetch field values in bulk. The caveat is an extra round-trip per page, but no breaking changes.

  • Added SearchIssueResult / SearchIssuesResponse types to wrap REST search results with field_values
  • Added searchIssuesNodesQuery GraphQL struct for the nodes(ids:) batch lookup
  • Added fetchIssueFieldValuesByNodeID helper that runs one GraphQL round-trip per page of results
  • Added searchIssuesHandler that wires REST search + enrichment, called from the search_issues tool
  • Extracted prepareSearchArgs from searchHandler so query-building logic is shared with search_pull_requests without coupling PR search to the enrichment path
  • Tests: Test_SearchIssues_FieldValuesEnrichment covers field_values population; existing Test_SearchIssues cases are unchanged

MCP impact

  • Tool schema or behavior changed — search_issues response shape gains items[].field_values (omitempty, non-breaking additive change). total_count and incomplete_results are now explicit top-level fields. list_issues also gains field_values on each result item (same omitempty, non-breaking).

Prompts tested (tool changes only)

  • "Search for open issues in github/issues repo with Priority P1 and show me their field values"

Security / limits

  • Data exposure, filtering, or token/size limits considered — field values fetched via nodes() respect the viewer's existing GraphQL permissions; no additional scopes required beyond repo.

Tool renaming

  • I am not renaming tools as part of this PR

Lint & tests

  • Linted locally with ./script/lint
  • Tested locally with ./script/test

Docs

  • Not needed

Adds Issues 2.0 custom field values to each issue returned by the
list_issues GraphQL query, exposed on MinimalIssue as field_values:
[{field, value}]. Filtering by field is a separate concern (needs the
GraphQL IssueFilters input updated upstream) and is not included here.

shurcooL/graphql's response decoder walks every inline fragment of a
union regardless of __typename, so IssueFieldNumberValue.value is
aliased to valueNumber to avoid a Float-vs-String type clash when the
runtime variant is, e.g., a SingleSelectValue.
After the REST search returns results, batch a single nodes(ids:[...]) GraphQL
query to fetch each issue's custom field values. The extra round-trip is one per
page of results. Non-breaking: field_values is omitempty and the response shape
is additive.

Also extracts prepareSearchArgs from searchHandler so the query-building logic
is shared with search_pull_requests without coupling PR search to the
issue-specific enrichment path.
@kelsey-myers kelsey-myers force-pushed the kelsey/search-issues-field-values branch from 900d2b9 to 856ce87 Compare May 13, 2026 16:09
@kelsey-myers kelsey-myers changed the title Add field_values enrichment to search_issues Add field_values to search_issues results May 13, 2026
@kelsey-myers kelsey-myers requested a review from Copilot May 13, 2026 16:41
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends issue search/listing paths to include custom issue field values from GraphQL while preserving REST-based search_issues pagination.

Changes:

  • Adds issue field value GraphQL fragments and minimal response types.
  • Adds search_issues REST search enrichment via a batched nodes(ids:) GraphQL query.
  • Updates issue listing/search tests to include field value fixtures.
Show a summary per file
File Description
pkg/github/search_utils.go Extracts shared search argument preparation and simplifies the generic search handler.
pkg/github/minimal_types.go Adds minimal issue field value output and maps GraphQL issue fragments into it.
pkg/github/issues.go Adds issue field GraphQL fragments, search enrichment logic, and wires it into search_issues.
pkg/github/issues_test.go Adds search field-value enrichment coverage and updates list issue GraphQL mocks/expectations.

Copilot's findings

Comments suppressed due to low confidence (1)

pkg/github/issues.go:252

  • This connection is capped at first: 25 without requesting pageInfo or documenting the limit, so issues with more than 25 custom field values will silently return an incomplete field_values array. Paginate the connection (or use a documented maximum that covers all issue fields) before presenting this as the issue's field values.
			IssueFieldValues struct {
				Nodes []IssueFieldValueFragment
			} `graphql:"issueFieldValues(first: 25)"`
  • Files reviewed: 4/4 changed files
  • Comments generated: 7

Comment thread pkg/github/issues.go
Comment on lines +1052 to +1053
idStr, ok := n.Issue.ID.(string)
if !ok || idStr == "" {
Comment thread pkg/github/issues.go
Comment thread pkg/github/issues.go Outdated
ClosedAt string `json:"closed_at,omitempty"`
ClosedBy string `json:"closed_by,omitempty"`
IssueType string `json:"issue_type,omitempty"`
FieldValues []MinimalIssueFieldValue `json:"field_values,omitempty"`
Comment thread pkg/github/issues.go
Comment on lines +1101 to +1103
fieldValuesByID, err = fetchIssueFieldValuesByNodeID(ctx, gqlClient, result.Issues)
if err != nil {
return ghErrors.NewGitHubGraphQLErrorResponse(ctx, errorPrefix+": failed to fetch issue field values", err), nil
Comment thread pkg/github/issues_test.go
Comment thread pkg/github/issues_test.go
@ZahidDigitalHQ
Copy link
Copy Markdown

  • name: GitHub App token
    uses: tibdex/github-app-token@v2.1.0

@ZahidDigitalHQ
Copy link
Copy Markdown

kelsey-myers:kelsey/search-issues-field-values

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants