Skip to content

Conversation

@niveshdandyan
Copy link
Contributor

@niveshdandyan niveshdandyan commented Feb 3, 2026

BREAKING CHANGE: User.Permissions is now *RepositoryPermissions instead of map[string]bool.

Summary

Replace map[string]bool with *RepositoryPermissions struct for the User.Permissions field.

Fixes #3947

Changes

  • Changed User.Permissions from map[string]bool to *RepositoryPermissions
  • Updated related tests to use the struct format
  • Regenerated accessor functions

Rationale

According to the List Collaborators API docs, the permissions object has a fixed, well-defined structure with pull, triage, push, maintain, and admin boolean fields.

Using the existing RepositoryPermissions struct provides:

  • Better type safety
  • Consistency with Repository.Permissions
  • IDE autocompletion for permission fields

Breaking Change

This is a breaking API change as noted in the issue labels. Users who access User.Permissions will need to update their code from map access (u.Permissions["pull"]) to struct access (u.GetPermissions().GetPull()).

Testing

All existing tests pass with the updated types.

Replace map[string]bool with *RepositoryPermissions struct for the
User.Permissions field, providing better type safety and consistency
with the existing Repository.Permissions field.

The permissions object has a well-defined structure according to the
GitHub API docs, making a struct more appropriate than a dynamic map.

Fixes google#3947
@google-cla
Copy link

google-cla bot commented Feb 3, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@gmlewis gmlewis changed the title refactor: use RepositoryPermissions struct for User.Permissions refactor!: Use RepositoryPermissions struct for User.Permissions Feb 3, 2026
@gmlewis gmlewis added NeedsReview PR is awaiting a review before merging. Breaking API Change PR will require a bump to the major version num in next release. Look here to see the change(s). labels Feb 3, 2026
@codecov
Copy link

codecov bot commented Feb 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.51%. Comparing base (91d01f7) to head (5d68936).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3963   +/-   ##
=======================================
  Coverage   85.51%   85.51%           
=======================================
  Files         204      204           
  Lines       17554    17554           
=======================================
  Hits        15011    15011           
  Misses       1913     1913           
  Partials      630      630           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Collaborator

@gmlewis gmlewis left a comment

Choose a reason for hiding this comment

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

Thank you, @niveshdandyan!
LGTM.
Awaiting second LGTM+Approval from any other contributor to this repo before merging.

cc: @stevehipwell - @alexandear - @zyfy29 - @Not-Dhananjay-Mishra

Copy link
Contributor

@Not-Dhananjay-Mishra Not-Dhananjay-Mishra left a comment

Choose a reason for hiding this comment

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

LGTM

@gmlewis gmlewis removed the NeedsReview PR is awaiting a review before merging. label Feb 3, 2026
@gmlewis
Copy link
Collaborator

gmlewis commented Feb 3, 2026

Thank you, @Not-Dhananjay-Mishra!
Merging.

@gmlewis gmlewis merged commit 5126e84 into google:master Feb 3, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Breaking API Change PR will require a bump to the major version num in next release. Look here to see the change(s).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Modeling User.Permissions as struct instead of map[string]bool

3 participants