feat(api): Add organization_id_or_slug Support to Customer Domain Middleware#70172
Conversation
sentaur-athena
left a comment
There was a problem hiding this comment.
Changes makes sense to be but a hybrid cloud stamp would be nice. @dashed ?
| result.kwargs | ||
| and "organization_slug" in result.kwargs | ||
| and result.kwargs["organization_slug"] != activeorg | ||
| org_slug_path_mismatch = result.kwargs and ( |
There was a problem hiding this comment.
To make this easier to understand, with this solution, if ID is passed in organization_id_or_slug and it is not the correct ID of the active org redirect_url stays activeorg url but kwargs["organization_id_or_slug"] remain the wrong ID so this leads to 404. I think it's expected but just clarifying.
There was a problem hiding this comment.
Yep thats correct. In general, this scenario shouldn't be happening because the org_id should only be used in subdomain-less queries.
| # No redirect for id | ||
| response = self.client.get( | ||
| reverse("org-events-endpoint-id-or-slug", kwargs={"organization_id_or_slug": 1234}), | ||
| data={"querystring": "value"}, | ||
| HTTP_HOST="albertos-apples.testserver", | ||
| follow=True, | ||
| ) |
There was a problem hiding this comment.
In this scenario in saas, we'll end up going through the API gateway middleware and being proxied to the organization's region based on the 1234 slug and the subdomain will be ignored. I think that is a reasonable outcome as all slug subdomains resolve to control silo instances.
We are updating our APIs work with id and slug path params. We need to make sure that the middleware works with both type of path params. We need to make sure that if an orgid is passed, we don't redirect them.
For more context: https://sentry.slack.com/archives/C032E82D338/p1714605291155389
Example:
acme.sentry.io/organizations/12345/issuestohttp://12345.sentry.io/issues.