Skip to content

fix(api): add structured logs for sandbox delete 500/404 paths - #3530

Open
AdaAibaby wants to merge 1 commit into
e2b-dev:mainfrom
AdaAibaby:fix/sandbox-delete-missing-structured-logs
Open

fix(api): add structured logs for sandbox delete 500/404 paths#3530
AdaAibaby wants to merge 1 commit into
e2b-dev:mainfrom
AdaAibaby:fix/sandbox-delete-missing-structured-logs

Conversation

@AdaAibaby

@AdaAibaby AdaAibaby commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Fixes #3529

Problem

DeleteSandboxesSandboxID has three logging gaps:

  1. ErrSandboxOperationFailed → 500 with no log or telemetry — the most common 500 cause (node unreachable, gRPC error) emits nothing to Loki and records no span error.
  2. deleteSnapshot failure message is ambiguous"error deleting sandbox" does not distinguish kill failure from DB failure.
  3. 404 logged at Debug level, no teamID — suppressed in production; 404 frequency per team is invisible.

Changes

packages/api/internal/handlers/sandbox_kill.go:

Branch Before After
ErrSandboxOperationFailed no log Error + sandbox_id + team_id + zap.Error + telemetry.ReportError
deleteSnapshot != nil telemetry.ReportError only Error log with distinct message "Failed to delete sandbox snapshot from DB"
default unexpected error telemetry.ReportError only Error log added
ErrSandboxNotFound Debug Info + team_id
final 404 Debug, no team_id Info + team_id, message "not running and no snapshot"

Why this is not a duplicate

Searched open PRs for sandbox delete log, sandbox kill log, sandbox 500 log — no existing PR covers this.

Test plan

  • go build ./packages/api/internal/handlers/ passes
  • go vet ./packages/api/... passes
  • Manually trigger a 500 (sandbox on unreachable node) → confirm "Failed to kill sandbox on orchestrator node" in Loki with sandbox_id and team_id
  • Manually trigger a 404 (non-existent sandbox) → confirm "Sandbox not found: not running and no snapshot" at Info level

/cc @jakubno @dobrac @ValentaTomas @arkamar @tvi @tomassrnka Looking forward to your code review.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(api): DELETE /sandboxes/{id} returns 500/404 with no structured log — root cause invisible

2 participants