raystack / frontier

Frontier is an all-in-one user management platform that provides identity, access and billing management to help organizations secure their systems and data. (Open source alternative to Clerk)
https://raystack-frontier.vercel.app/
Apache License 2.0
273 stars 34 forks source link

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

Closed rsbh closed 1 month ago

rsbh commented 1 month ago

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.

vercel[bot] commented 1 month ago

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 commented 1 month ago

Pull Request Test Coverage Report for Build 11551576193

Details


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

💛 - Coveralls