-
Notifications
You must be signed in to change notification settings - Fork 9
fix(tasks): admins can fetch any task by id (unblocks customer-prompt-task) #689
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Oops, something went wrong.
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.
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.
DRY - do we already have a shared lib to check for
org+adminaccount gating? If so, we should use the existing libs instead of directly inlining checkIsAdmin. Check neighboring validate functions.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.
Good check — I looked at the neighbors. A few findings:
The change already calls the shared helper, not inlined logic.
checkIsAdmin(authResult.accountId)is the sharedlib/admins/checkIsAdmin.ts(→validateOrganizationAccess(accountId, RECOUP_ORG_ID)). No org-membership query is inlined here.It's the established neighbor pattern. The closest sibling —
lib/tasks/validateGetTaskRunQuery.ts(GET /api/tasks/runs) — uses the identicalcheckIsAdminadmin-bypass shape, and this same file's existingaccount_id-override branch already imports and usescheckIsAdmin. I reused that import rather than introducing a new gating call.The other org helpers don't fit better here:
lib/organizations/canAccessAccount.tsneeds atargetAccountId(caller-vs-target). My case has no target account — an admin reads any task byid, owner unknown until fetched. Using it would mean restructuring to fetch-then-authorize, and it also grants shared-org access (org-mates, not just Recoup admins) — broader than this bugfix's intended scope (issue chat#1810 deliberately scopes to admin-only).lib/organizations/isRecoupAdmin.tsis functionally equivalent tocheckIsAdminbut via a different query; switching to it would make this validator inconsistent with itslib/taskssiblings.So I kept
checkIsAdminfor neighbor-consistency. Happy to switch to the org-awarecanAccessAccount(fetch-then-authorize) if you want org-mates — not just Recoup admins — to read each other's tasks by id; that's a scope decision, so flagging rather than assuming.