Skip to content
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

feat(api-idorslug): Rename Path paramaters to organization_id_or_slug #70081

Closed

Conversation

iamrajjoshi
Copy link
Member

@iamrajjoshi iamrajjoshi commented May 1, 2024

I am working on making our APIs work with slug and id in our path parameters. Over the path month, we have updated the endpoints so they can support both parameters. As a final step, we are renaming the parameters from {resource}.slug to {resource}.id_or_slug.

A Breakdown of the changes:
#70378
#70384
#70389

For more information, refer to: https://www.notion.so/sentry/Make-APIs-work-with-Slug-ID-cbaf68b883b843d499191e9cc4c116d3 and #69716 (comment)

@iamrajjoshi iamrajjoshi self-assigned this May 1, 2024
@github-actions github-actions bot added Scope: Frontend Automatically applied to PRs that change frontend components Scope: Backend Automatically applied to PRs that change backend components labels May 1, 2024
Copy link
Contributor

github-actions bot commented May 1, 2024

🚨 Warning: This pull request contains Frontend and Backend changes!

It's discouraged to make changes to Sentry's Frontend and Backend in a single pull request. The Frontend and Backend are not atomically deployed. If the changes are interdependent of each other, they must be separated into two pull requests and be made forward or backwards compatible, such that the Backend or Frontend can be safely deployed independently.

Have questions? Please ask in the #discuss-dev-infra channel.

Copy link

codecov bot commented May 1, 2024

Bundle Report

Bundle size has no change ✅

Copy link
Member

@sentaur-athena sentaur-athena left a comment

Choose a reason for hiding this comment

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

I reviewed till organization_integrations.py will be back 😅

@@ -87,115 +87,115 @@
}
],
Copy link
Member

Choose a reason for hiding this comment

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

I hate this json file 😭 looking forward to a day when we delete it #wishful-thinking

*args: Any,
**kwargs: Any,
) -> tuple[tuple[Any, ...], dict[str, Any]]:
if not subdomain_is_region(request):
subdomain = getattr(request, "subdomain", None)
if subdomain is not None and subdomain != organization_slug:
if subdomain is not None and subdomain != organization_id_or_slug:
Copy link
Member

Choose a reason for hiding this comment

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

Subdomain is never ID. Does this mean it would fail anytime we use the API with ID?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think this is related to my question here: https://sentry.slack.com/archives/C032E82D338/p1714605291155389, the git blame is related to customer domain stuff.

Copy link
Member Author

Choose a reason for hiding this comment

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

tldr from the thread: this would fail if we get a request like acme.sentry.io/organizations/12345/issues because we wouldn't redirect the user to http://12345.sentry.io/issues. However, most of our customers will hit our endpoints with ids programmatically, so we should be good!

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

@sentaur-athena sentaur-athena left a comment

Choose a reason for hiding this comment

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

Done ✅ Will review new commits as they come.

organization_id_or_slug = kwargs.pop("organization_id_or_slug", None) or kwargs.pop(
"organization_slug"
)

if args and args[0] is not None:
project_id_or_slug: int | str = args[0]
Copy link
Member

Choose a reason for hiding this comment

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

I don't get this. So args[0] is both project slug and org slug?!

Edit: Oh I see. You're removing args one by one. Why not keeping organization_slug as a named arg organization_id_or_slug? Like what you do with the rest of convert_args

Copy link
Member Author

Choose a reason for hiding this comment

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

This is a temporary jerry rig so that we maintain backwards compatibility with getsentry endpoints until I update them. They expect convert_args to accept organization_slug, so I can't keep it named, I have to keep it unnamed and extract it. I don't like it, but couldn't think of a better way.

Copy link
Member

Choose a reason for hiding this comment

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

Please add a TODO comment and make sure they will be done right after. I see your point.

Copy link
Contributor

Choose a reason for hiding this comment

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

Does org ever get passed as a kwarg?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nope it isn't, Org is above Project in the hierarchy

src/sentry/api/endpoints/broadcast_index.py Outdated Show resolved Hide resolved
iamrajjoshi added a commit that referenced this pull request May 9, 2024
…ints to use `organization_id_or_slug` (#70567)

A subset of changes from #70081!

---------

Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com>
iamrajjoshi added a commit that referenced this pull request May 13, 2024
…ests to use `organization_id_or_slug` (#70711)

A subset of changes from #70081!
@github-actions github-actions bot locked and limited conversation to collaborators Jun 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Scope: Backend Automatically applied to PRs that change backend components Scope: Frontend Automatically applied to PRs that change frontend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants