fix: Call the decorated function in require_permissions - #6844
Open
David-Wu1119 wants to merge 1 commit into
Open
David-Wu1119 wants to merge 1 commit into
David-Wu1119 wants to merge 1 commit into
Conversation
`permission_checker` returned the result of `assert_permissions(...)`, which is the resource itself, so the code below it — including `func(*args, **kwargs)` — was unreachable. Every method decorated with `@require_permissions` skipped its own body and returned the resource instead. The permission check itself still worked (`assert_permissions` raises `FeastPermissionError` when access is denied), which is why the existing tests passed: they only asserted that permitted calls do not raise, never that the decorated method actually ran. Drop the `return` so `assert_permissions` keeps acting as a guard and the decorated function is called, and assert the returned value in `test_access_SecuredFeatureView` so the regression cannot come back. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Signed-off-by: David-Wu1119 <133224895+David-Wu1119@users.noreply.github.com>
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #6844 +/- ##
==========================================
+ Coverage 47.11% 47.42% +0.30%
==========================================
Files 419 421 +2
Lines 51886 52252 +366
Branches 7528 7582 +54
==========================================
+ Hits 24448 24780 +332
- Misses 25688 25708 +20
- Partials 1750 1764 +14
... and 13 files with indirect coverage changes Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
This branch has not been deployed
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 this PR does / why we need it:
require_permissionsnever calls the function it decorates.assert_permissionsreturns the resource it was given, so every method decorated with@require_permissionsskips its own body and returns the resource instead of its own return value. This has been the behaviour since the decorator was added in #4380.The permission check itself still works —
assert_permissionsraisesFeastPermissionErrorwhen access is denied — so this is not a security hole, it is a silent no-op for the protected method.Demonstrated on
masterwith the existing test fixtures (SecuredFeatureView.read_protected()is defined asreturn True):The fix drops the
returnin front ofassert_permissions(...), which leaves it acting as a guard and makes the rest of the wrapper reachable again.test_access_SecuredFeatureViewpassed before this change because it only asserted that permitted calls do not raise, never that the decorated method ran, so the two permitted branches now assert the returned value as well. Reverting the one-line source change makes 3 of its 4 parametrizations fail.Which issue(s) this PR fixes:
None filed.
Checks
git commit -s)Testing Strategy
(
tests/unit/permissions/authwas skipped locally: it needs optional auth dependencies that are not installed in my environment.)ruff checkandruff format --checkare clean on both changed files.Misc
The always-true early return was found with an AST scan for statements after an unconditional
return/raise. The change and this description were written with AI assistance and reviewed line by line.🤖 Generated with Claude Code