-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
feat(prevent): create endpoint that fetches repositories list #95181
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
base: master
Are you sure you want to change the base?
Conversation
request=None, | ||
responses={ | ||
200: RepositoriesSerializer, | ||
400: RESPONSE_BAD_REQUEST, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're up for it, one thing I didn't do with my initial implementation of the serializers with the test results one is to actually throw the exceptions in the serializer if we error out on the owner part of the request.
https://github.com/codecov/umbrella/blob/02de63009831bee26cb65113b35f6ef53ed32a3b/apps/codecov-api/graphql_api/types/repository/repository.graphql#L95 All of this stuff basically would be in the GQL request IIRC.
But for repositories also maybe not, because it returns a set of RepositoryConnections, in which case idk when we'd return 404 or 403 🤔 Something we can maybe talk about later
Codecov ReportAttention: Patch coverage is ✅ All tests successful. No failed tests found.
Additional details and impacted files@@ Coverage Diff @@
## master #95181 +/- ##
==========================================
+ Coverage 87.83% 87.84% +0.01%
==========================================
Files 10478 10487 +9
Lines 605897 605479 -418
Branches 23668 23586 -82
==========================================
- Hits 532177 531880 -297
+ Misses 73356 73239 -117
+ Partials 364 360 -4 |
Is there a tech spec detailing which new API endpoints we're implementing within Sentry? We probably need security to review these and the data we're ferrying to Codecov in the process. |
src/sentry/api/urls.py
Outdated
@@ -3307,6 +3308,11 @@ def create_group_urls(name_prefix: str) -> list[URLPattern | URLResolver]: | |||
TestResultsAggregatesEndpoint.as_view(), | |||
name="sentry-api-0-test-results-aggregates", | |||
), | |||
re_path( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i realize this is beyond the scope of this - but these URLs are not maintainable - they should all be prefixed if we're allowing repo access outside of org-scoped queries
e.g. /gh-repos/ or something similar
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dcramer We actually just moved these over to be org scoped hehe. This one will be rebased and further created endpoints will follow suit
Related slack thread: https://sentry.slack.com/archives/C08HLC09Z8A/p1752079936486329
@GabeVillalobos We're pulling data from Codecov rather than ferrying to Codecov, unless you mean the request parameters for these endpoints? |
@ajay-sentry Yep, I'm mainly interested in request parameters, or request bodies for future PUT/POST requests. |
@@ -1065,6 +1066,11 @@ def create_group_urls(name_prefix: str) -> list[URLPattern | URLResolver]: | |||
TestResultsAggregatesEndpoint.as_view(), | |||
name="sentry-api-0-test-results-aggregates", | |||
), | |||
re_path( | |||
r"^owner/(?P<owner>[^/]+)/repositories/$", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
man, this made me realize I probably should've named the other routes repositories rather than repository, maybe I can do a follow up on this
} | ||
} | ||
pageInfo { | ||
endCursor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also add hasPreviousPage and startCursor?
), f"Response keys {response_keys} don't match serializer fields {serializer_fields}" | ||
|
||
@patch("sentry.codecov.endpoints.Repositories.repositories.CodecovApiClient") | ||
def test_get_with_query_parameters(self, mock_codecov_client_class): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is just testing for the "term" query parameter right? Not all of them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will add test w/ all the query params
assert response.status_code == 200 | ||
|
||
@patch("sentry.codecov.endpoints.Repositories.repositories.CodecovApiClient") | ||
def test_get_with_last_parameter(self, mock_codecov_client_class): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wonder if we should do a similar thing like we did in test_results where we just had the "no response mock" be a const at the top of the file so we can keep the rest of the test pretty lean
try: | ||
first = int(first_param) if first_param is not None else None | ||
last = int(last_param) if last_param is not None else None | ||
except ValueError: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we add some simple tests for these error responses?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mostly small stuff, looks good
This PR creates and endpoint that fetches a list of repositories belonging to a specific owner
Notes