Skip to content

Commit f0fd202

Browse files
julianknutsenclaude
andcommitted
fix: suppress Sentry capture for transient DoltHub "no such repository" errors
DoltHub intermittently returns "no such repository" for hop/wl-commons during brief unavailability windows, flooding Sentry with 76+ events (WASTELAND-3, WASTELAND-9). The 503 response and stale-cache fallback were already correct; this just stops the Sentry noise while preserving slog.Error for log-based observability. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 038ba88 commit f0fd202

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

internal/api/handlers.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ func (s *Server) handleBrowse(w http.ResponseWriter, r *http.Request) {
7878
// No stale data — return a 503 with a clear outage message.
7979
msg := "Upstream database is temporarily unavailable — please try again in a moment."
8080
slog.Error("browse failed with no stale data", "error", err)
81-
sentry.CaptureException(err)
81+
if !isTransientUpstreamError(err) {
82+
sentry.CaptureException(err)
83+
}
8284
writeJSON(w, http.StatusServiceUnavailable, ErrorResponse{Error: msg})
8385
return
8486
}
@@ -125,7 +127,9 @@ func (s *Server) handleDetail(w http.ResponseWriter, r *http.Request) {
125127
}
126128
msg := "Upstream database is temporarily unavailable — please try again in a moment."
127129
slog.Error("detail failed with no stale data", "error", err)
128-
sentry.CaptureException(err)
130+
if !isTransientUpstreamError(err) {
131+
sentry.CaptureException(err)
132+
}
129133
writeJSON(w, http.StatusServiceUnavailable, ErrorResponse{Error: msg})
130134
return
131135
}
@@ -243,6 +247,13 @@ func isUpstreamAuthError(err error) bool {
243247
return strings.Contains(err.Error(), "invalid authorization")
244248
}
245249

250+
// isTransientUpstreamError returns true if the error is a known-transient
251+
// DoltHub condition that doesn't warrant a Sentry alert (e.g. "no such
252+
// repository" when DoltHub temporarily can't resolve a repo).
253+
func isTransientUpstreamError(err error) bool {
254+
return strings.Contains(err.Error(), "no such repository")
255+
}
256+
246257
// writeUpstreamError classifies DoltHub errors and writes an appropriate response:
247258
// - "invalid authorization" → 401 (triggers frontend re-auth)
248259
// - other upstream errors → 503 with sanitized message + Sentry capture
@@ -252,7 +263,9 @@ func writeUpstreamError(w http.ResponseWriter, err error, label string) {
252263
return
253264
}
254265
slog.Error(label+" failed", "error", err)
255-
sentry.CaptureException(err)
266+
if !isTransientUpstreamError(err) {
267+
sentry.CaptureException(err)
268+
}
256269
writeError(w, http.StatusServiceUnavailable,
257270
"Upstream database is temporarily unavailable — please try again in a moment.")
258271
}

0 commit comments

Comments
 (0)