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

fix: check for resource.ErrNotExist error in check permission #808

Merged
merged 1 commit into from
Oct 28, 2024

Conversation

rsbh
Copy link
Member

@rsbh rsbh commented Oct 28, 2024

Problem.
If a random ID is passed in the CheckFederatedResourcePermission API resource body. The API throws an Internal error. And in the server logs, the error is resource doesn't exist.
After debugging, I found that we fetch the resource from the db, and it returns ErrNotExist error.
This error was not handled in the API handler function.

This PR adds a check for the resource.ErrNotExist error. It also refactors the switch statement.

@rsbh rsbh requested a review from kushsharma October 28, 2024 10:01
Copy link

vercel bot commented Oct 28, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
frontier ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 28, 2024 10:01am

@coveralls
Copy link

Pull Request Test Coverage Report for Build 11551576193

Details

  • 0 of 1 (0.0%) changed or added relevant line in 1 file are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+0.003%) to 30.829%

Changes Missing Coverage Covered Lines Changed/Added Lines %
internal/api/v1beta1/permission_check.go 0 1 0.0%
Files with Coverage Reduction New Missed Lines %
internal/api/v1beta1/permission_check.go 1 34.13%
Totals Coverage Status
Change from base Build 11516797820: 0.003%
Covered Lines: 7623
Relevant Lines: 24727

💛 - Coveralls

Copy link
Contributor

@anujk14 anujk14 left a comment

Choose a reason for hiding this comment

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

lgtm

@anujk14 anujk14 merged commit 65dc0c8 into main Oct 28, 2024
7 checks passed
@anujk14 anujk14 deleted the fix_check_permission_404_resource_not_exist branch October 28, 2024 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants