Skip to content

fix(backend): add catching various unhandled errors#2457

Open
kosmoz wants to merge 9 commits into
mainfrom
kosmoz/dev-623-improve-endpoint-error-handling
Open

fix(backend): add catching various unhandled errors#2457
kosmoz wants to merge 9 commits into
mainfrom
kosmoz/dev-623-improve-endpoint-error-handling

Conversation

@kosmoz
Copy link
Copy Markdown
Contributor

@kosmoz kosmoz commented May 21, 2026

No description provided.

kosmoz added 7 commits May 21, 2026 16:21
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>
@kosmoz kosmoz requested a review from pmig May 21, 2026 14:44
Signed-off-by: Jakob Steiner <jakob.steiner@glasskube.eu>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 for types.UserRole and types.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.

Comment thread internal/handlers/customer_organizations.go Outdated
Signed-off-by: Jakob Steiner <jakob.steiner@glasskube.eu>
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.

2 participants