8000 Add databaseId to assignees GraphQL fragment by srt32 · Pull Request #12783 · cli/cli · GitHub
[go: up one dir, main page]

Skip to content

Add databaseId to assignees GraphQL fragment#12783

Merged
BagToad merged 1 commit intocli:trunkfrom
srt32:fix-assignee-databaseid
Feb 28, 2026
Merged

Add databaseId to assignees GraphQL fragment#12783
BagToad merged 1 commit intocli:trunkfrom
srt32:fix-assignee-databaseid

Conversation

@srt32
Copy link
Contributor
@srt32 srt32 commented Feb 25, 2026

Summary

  • Fixes databaseId always being 0 for assignees in --json output (e.g. gh issue view --json assignees)
  • The GitHubUser struct already has a DatabaseID field, but the GraphQL query fragment for assignees never requested databaseId from the API, so it always defaulted to Go's zero value

Details

The assignees fragment in query_builder.go requested only id, login, and name:

assignees(first:100){nodes{id,login,name},totalCount}

This meant the DatabaseID int64 field on GitHubUser was never populated, producing "databaseId": 0 in JSON output. The fix adds databaseId to the fragment:

assignees(first:100){nodes{id,login,name,databaseId},totalCount}

PullRequestGraphQL delegates to IssueGraphQL, so both issue and PR queries are fixed by this single change.

Behavioral note

This is an additive change to --json assignees output — databaseId will now contain the real value instead of 0. This is not breaking for JSON consumers, but downstream scripts doing strict schema validation may notice the corrected field.

Testing

  • Updated query builder tests in query_builder_test.go for both TestPullRequestGraphQL and TestIssueGraphQL to expect the new field in the query string
  • Added ExportData round-trip test cases in export_pr_test.go for both TestIssue_ExportData and TestPullRequest_ExportData that verify a non-zero databaseId (1234) survives JSON serialization

@github-actions github-actions bot added external pull request originating outside of the CLI core team needs-triage needs to be reviewed labels Feb 25, 2026
The assignees query fragment only requested id, login, and name but the
GitHubUser struct includes a DatabaseID field. Since the field was never
requested from the API, it always defaulted to Go's zero value (0) in
JSON output. This adds databaseId to the fragment so the actual value is
returned.

Also adds ExportData test cases for assignees on both Issue and
PullRequest to verify databaseId round-trips correctly through JSON
serialization.
@srt32 srt32 force-pushed the fix-assignee-databaseid branch from 593c8b1 to 34c3b3c Compare February 25, 2026 15:27
@srt32 srt32 marked this pull request as ready for review February 25, 2026 15:28
@srt32 srt32 requested a review from a team as a code owner February 25, 2026 15:28
@srt32 srt32 requested review from BagToad and Copilot February 25, 2026 15:28
Copy link
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 fixes databaseId always being 0 for assignees in --json outputs by ensuring the assignees GraphQL fragment requests databaseId, allowing the existing GitHubUser.DatabaseID field to be populated correctly.

Changes:

  • Add databaseId to the assignees GraphQL fragment generated by IssueGraphQL (and therefore PullRequestGraphQL).
  • Update query builder string expectations in unit tests.
  • Add export round-trip tests to verify databaseId for assignees survives JSON serialization for both issues and pull requests.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
api/query_builder.go Extends the assignees GraphQL selection set to include databaseId.
api/query_builder_test.go Updates expected query fragments to include databaseId for assignees.
api/export_pr_test.go Adds regression tests ensuring assignee databaseId is non-zero and preserved in exported JSON.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Member
@BagToad BagToad left a comment

Choose a reason for hiding this comment

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

LGTM - thanks!

@BagToad BagToad enabled auto-merge February 28, 2026 19:17
@BagToad BagToad merged commit 097bad6 into cli:trunk Feb 28, 2026
34 of 35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external pull request originating outside of the CLI core team needs-triage needs to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

0