Skip to content

feat: Add list repo tokens endpoint #97007

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 4, 2025
Merged

Conversation

ajay-sentry
Copy link
Contributor

@ajay-sentry ajay-sentry commented Aug 1, 2025

This PR aims to add the list tokens endpoint for showing all the repo tokens for a particular organization.

Closes https://linear.app/getsentry/issue/CCMRG-1310/create-list-endpoint-for-repository-tokens

Depends on codecov/umbrella#371 which adds a new "token" property to the repository resolver which bypasses some other checks we have on the uploadToken endpoint. I didn't want to make the modifications to the uploadToken endpoint directly because then Gazebo would probably break and/or it'd just look really hacky.

Follows similar conventions to the list repositories endpoint, just a slightly different GQL query

Screenshot 2025-08-01 at 1 29 02 PM

Hiding all the token info for privacy

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

@ajay-sentry ajay-sentry requested review from a team as code owners August 1, 2025 20:28
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Aug 1, 2025
Retrieves a paginated list of repository tokens for a given owner.
"""

navigation = request.query_params.get("navigation", NavigationParameter.NEXT.value)
Copy link
Member

Choose a reason for hiding this comment

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

could we use a serializer to format the query parameters? e.g.

serializer = AuditLogQueryParamSerializer(data=request.GET)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Definitely on our list to clean up and create some consolidated serializers once we have a working beta; things are a little too flexible to commit to something outright just yet


navigation = request.query_params.get("navigation", NavigationParameter.NEXT.value)
limit_param = request.query_params.get("limit", MAX_RESULTS_PER_PAGE)
cursor = request.query_params.get("cursor")
Copy link
Member

Choose a reason for hiding this comment

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

it it possible to use our standardized pagination, like in other sentry endpoints?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately not, we've taken the approach to use Codecov's GQL paginator directly to avoid any additional hacks and bandages we might need to cut through and/or workaround. Its just a lot simpler for us this way

Copy link

codecov bot commented Aug 1, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #97007      +/-   ##
==========================================
- Coverage   80.68%   80.11%   -0.57%     
==========================================
  Files        8496     8498       +2     
  Lines      374236   379507    +5271     
  Branches    24287    24287              
==========================================
+ Hits       301940   304040    +2100     
- Misses      71919    75090    +3171     
  Partials      377      377              

token = serializers.CharField()


class RepositoryTokensSerializer(serializers.Serializer):
Copy link
Member

Choose a reason for hiding this comment

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

we generally try to standardize on using a sentry response serializer, which can then work with our paginator classes. https://develop.sentry.dev/backend/api/serializers/#model-serializer.

Copy link

linear bot commented Aug 4, 2025

Copy link
Contributor

@calvin-codecov calvin-codecov left a comment

Choose a reason for hiding this comment

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

Nice!

@ajay-sentry ajay-sentry merged commit e678268 into master Aug 4, 2025
70 of 71 checks passed
@ajay-sentry ajay-sentry deleted the Ajay/1310-repo-token-list branch August 4, 2025 17:48
andrewshie-sentry pushed a commit that referenced this pull request Aug 4, 2025
This PR aims to add the list tokens endpoint for showing all the repo
tokens for a particular organization.

Closes
https://linear.app/getsentry/issue/CCMRG-1310/create-list-endpoint-for-repository-tokens

Depends on codecov/umbrella#371 which adds a new
"token" property to the repository resolver which bypasses some other
checks we have on the uploadToken endpoint. I didn't want to make the
modifications to the uploadToken endpoint directly because then Gazebo
would probably break and/or it'd just look really hacky.

Follows similar conventions to the list repositories endpoint, just a
slightly different GQL query

<img width="974" height="771" alt="Screenshot 2025-08-01 at 1 29 02 PM"
src="https://github.com/user-attachments/assets/7b943e90-1912-4b2b-a07d-7ec63cff8374"
/>


Hiding all the token info for privacy

<!--

  Sentry employees and contractors can delete or ignore the following.

-->

### Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated
in the State of Delaware in 2015 as Functional Software, Inc. and is
gonna need some rights from me in order to utilize my contributions in
this here PR. So here's the deal: I retain all rights, title and
interest in and to my contributions, and by keeping this boilerplate
intact I confirm that Sentry can use, modify, copy, and redistribute my
contributions, under Sentry's choice of terms.
ajay-sentry added a commit that referenced this pull request Aug 5, 2025
…token table (#97095)

This PR aims to create the hook for the new repo token list endpoint as
well as the pagination stuff for us to swap between pages in the repo
token table.

We also remove the createdAt stuff from the token regen table since that
doesn't exist on the codecov side. So there are a couple styling updates
there to reflect that too.

Follows similar conventions to
#96228

Depends on #97007

Closes
https://linear.app/getsentry/issue/CCMRG-1482/hook-up-list-endpoint
Closes
https://linear.app/getsentry/issue/CCMRG-1443/drop-column-for-token-creation-date

<img width="1070" height="851" alt="Screenshot 2025-08-04 at 10 58
32 AM"
src="https://github.com/user-attachments/assets/1cdac64e-2d6b-4118-aaff-6f61f1380738"
/>


<!--

  Sentry employees and contractors can delete or ignore the following.

-->

### Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated
in the State of Delaware in 2015 as Functional Software, Inc. and is
gonna need some rights from me in order to utilize my contributions in
this here PR. So here's the deal: I retain all rights, title and
interest in and to my contributions, and by keeping this boilerplate
intact I confirm that Sentry can use, modify, copy, and redistribute my
contributions, under Sentry's choice of terms.
andrewshie-sentry pushed a commit that referenced this pull request Aug 7, 2025
…token table (#97095)

This PR aims to create the hook for the new repo token list endpoint as
well as the pagination stuff for us to swap between pages in the repo
token table.

We also remove the createdAt stuff from the token regen table since that
doesn't exist on the codecov side. So there are a couple styling updates
there to reflect that too.

Follows similar conventions to
#96228

Depends on #97007

Closes
https://linear.app/getsentry/issue/CCMRG-1482/hook-up-list-endpoint
Closes
https://linear.app/getsentry/issue/CCMRG-1443/drop-column-for-token-creation-date

<img width="1070" height="851" alt="Screenshot 2025-08-04 at 10 58
32 AM"
src="https://github.com/user-attachments/assets/1cdac64e-2d6b-4118-aaff-6f61f1380738"
/>


<!--

  Sentry employees and contractors can delete or ignore the following.

-->

### Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated
in the State of Delaware in 2015 as Functional Software, Inc. and is
gonna need some rights from me in order to utilize my contributions in
this here PR. So here's the deal: I retain all rights, title and
interest in and to my contributions, and by keeping this boilerplate
intact I confirm that Sentry can use, modify, copy, and redistribute my
contributions, under Sentry's choice of terms.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants