Skip to content

Conversation

jakubno
Copy link
Member

@jakubno jakubno commented Oct 8, 2025

Note

Standardizes error handling across API, orchestrator, and proxy by replacing type assertions with errors.As/Is and introducing sentinel errors; updates related tests.

  • Errors/Handling:
    • Replace type-based checks with errors.As/errors.Is in packages/api/internal/handlers/*, orchestrator/*, and sandbox block code.
    • Introduce/use sentinel errors instead of custom types:
      • Auth: ErrNoAuthHeader now a sentinel (errors.New).
      • Proxy: replace InvalidHostError/InvalidSandboxPortError types with sentinel vars and use errors.Is in handler.go and host.go.
  • API:
    • sandbox_kill.go: handle db.EnvNotFoundError via errors.As.
    • template_build_status.go: handle db.TemplateBuildNotFoundError via errors.As.
  • Orchestrator:
    • pause_instance.go: detect PauseQueueExhaustedError via errors.As.
    • NBD pool: ReleaseDeviceWithRetry retries on DeviceInUseError via errors.As.
    • Block cache: chunk.go and overlay.go use errors.As for BytesNotAvailableError.
  • Tests:
    • Update memory store reservation tests to use require.ErrorAs for LimitExceededError and AlreadyBeingStartedError.

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

@jakubno jakubno added the bug Something isn't working label Oct 8, 2025
@e2b-request-same-site-reviewers e2b-request-same-site-reviewers bot requested review from sitole and removed request for ValentaTomas and dobrac October 8, 2025 11:31
cursor[bot]

This comment was marked as outdated.

@jakubno
Copy link
Member Author

jakubno commented Oct 8, 2025

Ideally we add https://github.com/fillmore-labs/errortype, but it isn't part of golangci-lint, so we would have to do custom setup.

I created fillmore-labs/errortype#5, let's see

@jakubno jakubno force-pushed the fix-errors-is-vs-as branch from e556777 to 273aa24 Compare October 8, 2025 11:36
cursor[bot]

This comment was marked as outdated.


if err != nil && !errors.Is(err, PauseQueueExhaustedError{}) {
var pauseQueueErr PauseQueueExhaustedError
if err != nil && !errors.As(err, &pauseQueueErr) {
Copy link

Choose a reason for hiding this comment

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

Bug: Redundant Error Variables in Function

The code declares two distinct variables of type PauseQueueExhaustedError (pauseQueueErrPauseExhausted and pauseQueueErr) for errors.As checks within the same function. This introduces redundant variable declarations and could lead to confusion.

Fix in Cursor Fix in Web

@jakubno jakubno marked this pull request as draft October 8, 2025 12:05
@jakubno jakubno changed the title Fix issues with error checks [WIP] Fix issues with error checks Oct 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant