Skip to content

Conversation

@dobrac
Copy link
Contributor

@dobrac dobrac commented Jan 6, 2026

Improves the template building error handling by not exposing internal server errors, simplifying user errors and adding tracking for the error types. This should help us improve tracking, alerting and regression monitoring.


Note

Improves reliability and observability of template builds with structured error handling and metrics.

  • New builderrors package: classifies errors as user vs internal, wraps context cancellations/timeouts as user errors, and returns generic internal messages via UnwrapUserError
  • Metrics: RecordBuildResult now tracks result as success|user_error|internal_error; build flow updated to set proper result type
  • Logging/telemetry: log user-facing messages for failures; report internal errors as critical and user errors as non-critical
  • OCI: wraps registry pull failures with user-friendly messages (e.g., not found/unauthorized) instead of low-level transport errors
  • Phases: NewPhaseBuildError now accepts PhaseMeta; propagate metadata through base/steps/finalize and rootfs creation; error wrapping standardized
  • Server: cancellation returns ErrCanceled message; panic handling avoids leaking internals; removed cache-level cancelled reason constant

Written by Cursor Bugbot for commit 9583660. This will update automatically on new commits. Configure here.

@dobrac dobrac added the improvement Improvement for current functionality label Jan 6, 2026
@dobrac dobrac force-pushed the chore/improve-error-handling-for-templates branch from 1f2deba to f54100c Compare January 6, 2026 21:33
@dobrac dobrac marked this pull request as ready for review January 6, 2026 21:39
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f54100c1c2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@jakubno jakubno assigned jakubno and unassigned sitole Jan 7, 2026
@dobrac dobrac enabled auto-merge (squash) January 7, 2026 11:37
@dobrac dobrac merged commit c9308ec into main Jan 7, 2026
27 checks passed
@dobrac dobrac deleted the chore/improve-error-handling-for-templates branch January 7, 2026 11:47
// If it's a timeout context, wrap it as a user error
if errors.Is(err, context.DeadlineExceeded) {
return phases.NewPhaseBuildError(phases.PhaseMeta{}, ErrTimeout)
}
Copy link

Choose a reason for hiding this comment

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

Internal errors masked when context is also canceled

Medium Severity

When an internal error occurs and the context is also canceled, the defer in builder.go joins them with errors.Join(e, ctx.Err()). Then WrapContextAsUserError checks errors.Is(err, context.Canceled) which finds the context error in the joined error and returns a new PhaseBuildError wrapping ErrCanceled, discarding the original internal error. This causes internal errors to be miscategorized as BuildResultUserError in metrics instead of BuildResultInternalError, undermining the PR's goal of improving error tracking and regression monitoring.

Additional Locations (1)

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Improvement for current functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants