Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: truncate error msg to 1024 chars (#8711)

p0nyaba0e13f4b21
diff --git a/backend/api/v1/debug_interceptor.go b/backend/api/v1/debug_interceptor.go
index fba7b2ce72..eac0260c2b 100644
--- a/backend/api/v1/debug_interceptor.go
+++ b/backend/api/v1/debug_interceptor.go
@@ -44,6 +44,15 @@ func (in *DebugInterceptor) DebugInterceptor(ctx context.Context, request any, s
resp, err := handler(ctx, request)
in.debugInterceptorDo(ctx, serverInfo.FullMethod, err, startTime)
+ // Truncate error message to 1024 characters.
+ st, _ := status.FromError(err)
+ if msg, truncated := common.TruncateString(st.Message(), 1024); truncated {
+ slog.Info("Truncated error message", slog.String("fullMethod", serverInfo.FullMethod), slog.String("original error message", st.Message()))
+ stp := st.Proto()
+ stp.Message = "[TRUNCATED] " + msg
+ err = status.FromProto(stp).Err()
+ }
+
return resp, err
}