MCPcopy Create free account
hub / github.com/PostHog/duckgres / TestLogQueryErrorRoutesInfraCancelToErrorLevel

Function TestLogQueryErrorRoutesInfraCancelToErrorLevel

server/transient_test.go:628–649  ·  view source on GitHub ↗

TestLogQueryErrorRoutesInfraCancelToErrorLevel locks in the alerting invariant: a worker-death cancellation (gRPC Canceled bubbling up while c.ctx is still healthy) must produce slog.LevelError "Query execution errored.", not Info "Query execution failed." — because the latter gets filtered out of a

(t *testing.T)

Source from the content-addressed store, hash-verified

626// filtered out of alerting and drove the dev/prod observability blind spot
627// reported on 2026-05-04 (PR #516).
628func TestLogQueryErrorRoutesInfraCancelToErrorLevel(t *testing.T) {
629 prevLogger := slog.Default()
630 defer slog.SetDefault(prevLogger)
631
632 var buf bytes.Buffer
633 slog.SetDefault(slog.New(slog.NewTextHandler(&buf, &slog.HandlerOptions{Level: slog.LevelDebug})))
634
635 c := &clientConn{ctx: context.Background(), username: "test"}
636 infraErr := errors.New("flight execute: rpc error: code = Canceled desc = context canceled")
637 c.logQueryError("SELECT 1", infraErr)
638
639 out := buf.String()
640 if !strings.Contains(out, `level=ERROR`) {
641 t.Errorf("expected ERROR level for infra cancel, got:\n%s", out)
642 }
643 if !strings.Contains(out, `Query execution errored.`) {
644 t.Errorf("expected message 'Query execution errored.', got:\n%s", out)
645 }
646 if strings.Contains(out, `Query execution failed.`) {
647 t.Errorf("infra cancel should NOT emit 'Query execution failed.':\n%s", out)
648 }
649}

Callers

nothing calls this directly

Calls 2

logQueryErrorMethod · 0.95
StringMethod · 0.45

Tested by

no test coverage detected