-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
feat(api): Add integration endpoint to project key serializer #101999
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
Conversation
| def integration_endpoint(self): | ||
| endpoint = self.get_endpoint() | ||
|
|
||
| return f"{endpoint}/api/{self.project_id}/integration/" |
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.
Bug: The integration_endpoint method is missing the @property decorator, causing it to return a method object instead of a string URL, which breaks API serialization.
(Severity: Critical 0.85 | Confidence: 1.00)
🔍 Detailed Analysis
The integration_endpoint method in the ProjectKey model is missing the @property decorator. Unlike other similar methods in the class, this causes it to return a bound method object instead of a string URL. When the ProjectKeySerializer serializes a ProjectKey instance, it attempts to include obj.integration_endpoint. This will raise a TypeError because a method object is not JSON serializable, causing the /api/0/projects/{organization}/{project}/keys/ endpoint to fail.
💡 Suggested Fix
Add the @property decorator to the integration_endpoint method in the ProjectKey model. This will ensure it returns a string URL, consistent with other endpoint properties in the class, and can be correctly serialized.
🤖 Prompt for AI Agent
Fix this bug. In src/sentry/models/projectkey.py at lines 268-271: The
`integration_endpoint` method in the `ProjectKey` model is missing the `@property`
decorator. Unlike other similar methods in the class, this causes it to return a bound
method object instead of a string URL. When the `ProjectKeySerializer` serializes a
`ProjectKey` instance, it attempts to include `obj.integration_endpoint`. This will
raise a `TypeError` because a method object is not JSON serializable, causing the
`/api/0/projects/{organization}/{project}/keys/` endpoint to fail.
Did we get this right? 👍 / 👎 to inform future reviews.
This comment was marked as outdated.
This comment was marked as outdated.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #101999 +/- ##
===========================================
+ Coverage 80.97% 80.99% +0.01%
===========================================
Files 8730 8730
Lines 388499 389176 +677
Branches 24632 24632
===========================================
+ Hits 314593 315195 +602
- Misses 73546 73621 +75
Partials 360 360 |
287ab98 to
94239c8
Compare
|
Alright I decided I'm not going to go with this. Instead we'll expose every endpoint individually from the project key serializer. Given we have a tabbed approach here (#102010) I think this makes more sense. If we need to refactor it, we can always easily do this in the future. |
Alright final try at #102083 and #101999. We expose the integration endpoint in the project key serializer. API consumers can build the integrations (similar to how the `build_integration_endpoint` method works) for all the integration's that we'll be exposing in Relay. We might eventually remove the `otlp_traces_endpoint` and `otlp_logs_endpoint`, but we can explore that afterwards.
Alright final try at #102083 and #101999. We expose the integration endpoint in the project key serializer. API consumers can build the integrations (similar to how the `build_integration_endpoint` method works) for all the integration's that we'll be exposing in Relay. We might eventually remove the `otlp_traces_endpoint` and `otlp_logs_endpoint`, but we can explore that afterwards.
In Relay we've moved toward an
integrationabstraction on endpoints to represent trace and log (and in the future metric) drain endpoints. For example, our current support for OTLP, or future support for Vercel/Netlify Log Drains.https://github.com/getsentry/relay/blob/b97e972470adb15ac5a479375752b2ede6adfd63/relay-server/src/endpoints/mod.rs#L84-L91
This PR adds that integration endpoint to the project key serializer. This will look something like so:
https://o4504765715316736.ingest.sentry.io/api/4505281256090153/integration/.By default something like
/api/4505281256090153/integration/will actually do nothing, as you'll need to provide further parameters to specify the integration you're using. For example/api/4505281256090153/integration/vercel/logsfor the vercel log drain endpoint, or/api/4505281256090153/integration/vercel/logs.From the integration endpoint, we can construct the rest of the endpoints easily. This does mean that the
ProjectKeySerializerbecomes less of a source of truth, but I think the increased flexibility means this is a good change.