fix(api): suppress logging for TypeORM EntityNotFoundError in resource access guards#4432
Open
fabjanvucina wants to merge 1 commit intomainfrom
Open
fix(api): suppress logging for TypeORM EntityNotFoundError in resource access guards#4432fabjanvucina wants to merge 1 commit intomainfrom
fabjanvucina wants to merge 1 commit intomainfrom
Conversation
…e access guards Signed-off-by: fabjanvucina <fabjanvucina@gmail.com>
|
View your CI Pipeline Execution ↗ for commit 9be8fca
☁️ Nx Cloud last updated this comment at |
There was a problem hiding this comment.
Pull request overview
This PR updates multiple API resource access guards to treat TypeORM EntityNotFoundError as an expected “not found” condition (like NestJS NotFoundException), avoiding unnecessary error logs and returning consistent 404 responses for missing resources.
Changes:
- Import
EntityNotFoundErrorin affected guards. - Update guard
catchblocks to skiplogger.errorwhen the caught error isNotFoundExceptionorEntityNotFoundError. - Keep consistent
NotFoundExceptionresponses for missing resources across guards.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| apps/api/src/docker-registry/guards/docker-registry-access.guard.ts | Suppress logging for EntityNotFoundError and normalize to NotFoundException. |
| apps/api/src/region/guards/region-access.guard.ts | Suppress logging for EntityNotFoundError and normalize to NotFoundException. |
| apps/api/src/sandbox/guards/job-access.guard.ts | Suppress logging for EntityNotFoundError and normalize to NotFoundException. |
| apps/api/src/sandbox/guards/runner-access.guard.ts | Suppress logging for EntityNotFoundError and normalize to NotFoundException. |
| apps/api/src/sandbox/guards/sandbox-access.guard.ts | Suppress logging for EntityNotFoundError and normalize to NotFoundException. |
| apps/api/src/sandbox/guards/snapshot-access.guard.ts | Suppress logging for EntityNotFoundError and normalize to NotFoundException. |
| apps/api/src/sandbox/guards/snapshot-read-access.guard.ts | Suppress logging for EntityNotFoundError and normalize to NotFoundException. |
| apps/api/src/sandbox/guards/volume-access.guard.ts | Suppress logging for EntityNotFoundError and normalize to NotFoundException. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
This pull request improves error handling across several access guard classes by ensuring that
EntityNotFoundErrorfrom TypeORM is treated as a "not found" condition, similar to NestJS'sNotFoundException. This prevents unnecessary logging of expected errors and provides more consistent error responses when resources are missing.Error Handling Improvements:
EntityNotFoundErrorfrom TypeORM and check for it alongsideNotFoundExceptionwhen handling errors, preventing unnecessary error logging for missing entities. [1] [2] [3] [4] [5] [6] [7] [8]EntityNotFoundError:DockerRegistryAccessGuardRegionAccessGuardJobAccessGuardRunnerAccessGuardSandboxAccessGuardSnapshotAccessGuardSnapshotReadAccessGuardVolumeAccessGuardThese changes ensure that missing resources are handled gracefully and consistently across the API.
Summary by cubic
Treat
typeorm’sEntityNotFoundErroras “not found” in resource access guards to stop logging expected errors and return consistent 404s. Applies to Docker registry, region, job, runner, sandbox, snapshot (read + write), and volume guards.EntityNotFoundErrorfromtypeormalongsideNotFoundException, suppress logging in these cases, and rethrow aNotFoundException.Written for commit 9be8fca. Summary will update on new commits.