Repository navigation
fix(api): Scope item and user lists and issue linking to an organization - #77
Draft
sentry-junior[bot] wants to merge 1 commit into
Draft
sentry-junior[bot] wants to merge 1 commit into
sentry-junior[bot] wants to merge 1 commit into
Conversation
GET /api/items/ and GET /api/users/ returned rows from every organization when the organization query parameter was missing or did not match an organization. Both backends now return 400 when it is missing and 404 when it is unknown, and only ever return the requested organization's rows. In the Python backend the user filter on /api/items/ is now also applied when items are enriched with Sentry data. The issue-link 'link' endpoint looked up the selected item by ID alone, so an installation could link a Sentry issue to another organization's item. It now only matches items in the installation's organization and returns 404 otherwise. Refs IE-93 Co-Authored-By: Matt Duncan <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes three places where one organization's data could be read or modified through another organization's request. Same change in both the Python and TypeScript backends.
Refs IE-93.
Changes
GET /api/items/andGET /api/users/Before: if
?organization=was missing, or didn't match an organization, the endpoint returned rows from every organization.After:
organization→400organization→404The frontend (
KanbanPage.tsx) is the only caller, and it always passes?organization=<slug>.Python only: on
/api/items/, theuserfilter used to be skipped when the request went through the Sentry-enrichment path. It's now applied in both paths.POST /api/sentry/issue-link/link/Before: the selected item was looked up by
itemIdalone, so an installation could link a Sentry issue to another organization's item.After: the lookup also matches the installation's organization, and returns
404if the item isn't found. Previously a missing item crashed with a 500.Files:
backend-py/src/api/endpoints/items.py,users.py,sentry/issue_link.pybackend-ts/src/api/items.ts,users.ts,sentry/issueLink.tsTests
Removed the two tests per backend that asserted the unscoped behavior (
GETwith no organization returns everything). Added:GETitems / users with no organization →400GETitems / users with an unknown organization →404404, and the item is left unchangeduserfilter combined withorganization, including a user from another organization → empty listAll the new tests fail against
main(7 Python, 5 TypeScript) and pass on this branch.Verification
backend-py:pytest60 passed (Python 3.13);black22.6.0 andflake84.0.1 clean on changed filesbackend-ts:jest44 passed;tsc --noEmitclean;eslintclean on changed files except a Prettier error insrc/api/items.tsline 18, which is also onmainorganization→400, unknown →404,acme→200for/api/users/(both) and/api/items/(TS)/api/items/?organization=acmeon the Python container returns500on bothmainand this branch. It's unrelated to this change:Item.sentry_id is not Noneinitems.pyalways evaluates toTrue, so every request goes down the Sentry-enrichment path and fails when the org has no Sentry installation.via matt.duncan.
--
View Junior Session [Sentry]