fix(file-service): 400 on revoke of an unknown email - #8384
Open
gupta-sahil01 wants to merge 1 commit into
Open
Conversation
Contributor
Automated Reviewer SuggestionsBased on the
|
Contributor
Backport auto-label reportThis
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8384 +/- ##
=========================================
Coverage 94.03% 94.04%
- Complexity 4771 4785 +14
=========================================
Files 1196 1196
Lines 48757 48778 +21
Branches 5916 5918 +2
=========================================
+ Hits 45850 45871 +21
Misses 1458 1458
Partials 1449 1449
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
What changes were proposed in this PR?
ResourceAccess.revokedereferenced the result ofUserDao.fetchOneByEmail(email)without a null check:fetchOneByEmailreturnsnullfor an address with no account, so revoking a dataset or model share for an unregistered email threw aNullPointerException. The service registers noExceptionMapperfor it, so it surfaced as an opaque HTTP 500 rather than an actionable 400.grant, in the same object, already performed the correct check. This PR extracts that check into a privateresolveUidByEmailhelper and routes bothgrantandrevokethrough it, mirroringComputingUnitAccessResource.resolveUidByEmailadded in #6446 for the same defect.Affected endpoints:
DELETE /api/access/dataset/revoke/{did}/{email}DELETE /api/access/model/revoke/{mid}/{email}Behaviour note:
revokenow also rejects placeholder accounts, matchinggrantandComputingUnitAccessResource.Any related issues, documentation, discussions?
Closes #8353.
Same defect as #6445, fixed in #6446 for
ComputingUnitAccessResourceonly. That fix's rationale assumed the dataset/model/project resources already behaved correctly — true of theirgrantpaths, but not theirrevokepaths.How was this PR tested?
Added
"reject a revoke for an email with no account"toDatasetAccessResourceSpecandModelAccessResourceSpec.Originally found on a local
bin/local-dev.shstack, whereDELETE /api/access/dataset/revoke/2/nobody@example.comreturned HTTP 500 with:Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code