fix(backend): add catching various unhandled errors#2457
Open
kosmoz wants to merge 9 commits into
Open
Conversation
Signed-off-by: Jakob Steiner <jakob.steiner@glasskube.eu>
Signed-off-by: Jakob Steiner <jakob.steiner@glasskube.eu>
Signed-off-by: Jakob Steiner <jakob.steiner@glasskube.eu>
Signed-off-by: Jakob Steiner <jakob.steiner@glasskube.eu>
Signed-off-by: Jakob Steiner <jakob.steiner@glasskube.eu>
Signed-off-by: Jakob Steiner <jakob.steiner@glasskube.eu>
Signed-off-by: Jakob Steiner <jakob.steiner@glasskube.eu>
Signed-off-by: Jakob Steiner <jakob.steiner@glasskube.eu>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR tightens backend input/error handling by adding stricter JSON unmarshalling for enum-like types, translating specific Postgres errors into apierrors categories, and improving OIDC callback validation to avoid unexpected failures.
Changes:
- Add
UnmarshalJSON+ parsing/validation fortypes.UserRoleandtypes.DeploymentType. - Improve HTTP handlers to treat certain DB/validation failures as
400 Bad Request(and harden OIDC callback handling for provider errors / missing params). - Make several DB operations return more specific
apierrors(e.g., FK violation → bad request) and make artifact “get or create” atomic via UPSERT.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| internal/types/types.go | Adds JSON unmarshalling/validation for UserRole and DeploymentType. |
| internal/handlers/customer_organizations.go | Attempts to surface DB “bad request” errors as HTTP 400 during customer org creation. |
| internal/handlers/auth_oidc.go | Adds better OIDC callback validation and maps some state issues to bad request. |
| internal/handlers/agent.go | Returns HTTP 400 when saving deployment target logs fails with ErrBadRequest. |
| internal/db/deployment_target_log_records.go | Maps FK violations during log record ingestion to apierrors.NewBadRequest. |
| internal/db/customer_organization.go | Maps a specific FK violation to apierrors.NewBadRequest("invalid image ID"). |
| internal/db/auth_oidc.go | Maps pgx.ErrNoRows to apierrors.ErrNotFound for OIDC state deletion. |
| internal/db/artifacts.go | Replaces SELECT-then-create with INSERT…ON CONFLICT UPSERT for atomic get-or-create. |
| .env.development.local | Adds REGISTRY_SCRATCH_DIR for local development configuration. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Jakob Steiner <jakob.steiner@glasskube.eu>
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.
No description provided.