Skip to content

Use int64 for GitHub database IDs#13403

Draft
williammartin wants to merge 1 commit into
trunkfrom
9247-ensure-the-cli-handles-github-database-ids-correctly
Draft

Use int64 for GitHub database IDs#13403
williammartin wants to merge 1 commit into
trunkfrom
9247-ensure-the-cli-handles-github-database-ids-correctly

Conversation

@williammartin
Copy link
Copy Markdown
Member

Use int64 for GitHub database IDs

Closes #9247

Problem

Several structs in the CLI use Go's int type for GitHub database ID fields. Go's int is platform-dependent and could be 32-bit on some architectures, while GitHub internally uses 64-bit integers for database IDs. The REST API OpenAPI spec explicitly declares many resource IDs as integer with format: int64 (e.g. repositories, GPG keys, SSH keys), and the GraphQL API has migrated some databaseId fields from Int to BigInt.

Changes

Updated all struct fields representing GitHub database IDs from int to int64, along with their downstream usage:

  • Codespaces: Repository.ID, CreateCodespaceParams.RepositoryID, startCreateRequest.RepositoryID, plus interface/mock/test cascading
  • Rulesets: RulesetGraphQL.DatabaseId, RulesetREST.Id, BypassActors.ActorId, RulesetRule.RulesetId, and the skills rulesetsResponse.ID
  • Keys: deployKey.ID, gpgKey.ID, sshKey.ID
  • Cache: Cache.Id
  • Autolinks: Autolink.ID
  • Agent tasks: JobActor.ID, JobPullRequest.ID

All strconv.Itoa() calls on these fields were updated to strconv.FormatInt(x, 10).

GraphQL response structs were also audited - only RulesetGraphQL.DatabaseId needed updating. Others were already correct (GitHubUser.DatabaseID is int64, FullDatabaseID is string for GraphQL BigInt).

Lint check

Added a custom go/analysis linter (cmd/idtype-checker) that flags struct fields with ID-like names or JSON tags that use int instead of int64. Integrated into make lint to prevent regressions.

Validation

  • go build ./... passes
  • All affected package tests pass
  • make lint reports 0 issues
  • Linter correctly catches all 27 pre-fix violations with zero false positives

Change all struct fields representing GitHub database IDs from int to
int64 to match the API spec and prevent potential overflow on 32-bit
architectures.

Add a custom go/analysis linter (idtype-checker) that flags struct
fields with ID-like names or JSON tags using int instead of int64,
integrated into make lint.

Closes #9247

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@williammartin williammartin linked an issue May 12, 2026 that may be closed by this pull request
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.

Ensure the CLI handles GitHub database IDs correctly

1 participant