Skip to content

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

chore: add panic recovers (#10351)

p0ny4ade25606135
diff --git a/backend/api/v1/acl_iam.go b/backend/api/v1/acl_iam.go
index 7bc2fac13a..2d9436f716 100644
--- a/backend/api/v1/acl_iam.go
+++ b/backend/api/v1/acl_iam.go
@@ -2,6 +2,7 @@ package v1
import (
"context"
+ "log/slog"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
@@ -10,11 +11,24 @@ import (
"github.com/bytebase/bytebase/backend/api/auth"
"github.com/bytebase/bytebase/backend/common"
+ "github.com/bytebase/bytebase/backend/common/log"
"github.com/bytebase/bytebase/backend/store"
v1pb "github.com/bytebase/bytebase/proto/generated-go/v1"
)
-func (in *ACLInterceptor) checkIAMPermission(ctx context.Context, fullMethod string, req any, user *store.UserMessage) error {
+func (in *ACLInterceptor) checkIAMPermission(ctx context.Context, fullMethod string, req any, user *store.UserMessage) (err error) {
+ defer func() {
+ if r := recover(); r != nil {
+ perr, ok := r.(error)
+ if !ok {
+ perr = errors.Errorf("%v", r)
+ }
+ err = errors.Errorf("iam check PANIC RECOVER, method: %v, err: %v", fullMethod, perr)
+
+ slog.Error("iam check PANIC RECOVER", log.BBError(perr), log.BBStack("panic-stack"))
+ }
+ }()
+
if isSkippedMethod(fullMethod) {
return nil
}
diff --git a/backend/runner/plancheck/executor.go b/backend/runner/plancheck/executor.go
index 481ad9770a..0a4166d588 100644
--- a/backend/runner/plancheck/executor.go
+++ b/backend/runner/plancheck/executor.go
@@ -17,8 +17,8 @@ func runExecutorOnce(ctx context.Context, exec Executor, config *storepb.PlanChe
if !ok {
panicErr = errors.Errorf("%v", r)
}
- slog.Error("TaskExecutor PANIC RECOVER", log.BBError(panicErr), log.BBStack("panic-stack"))
- err = errors.Errorf("encounter internal error when executing check")
+ slog.Error("planCheckExecutor PANIC RECOVER", log.BBError(panicErr), log.BBStack("panic-stack"))
+ err = errors.Errorf("planCheckExecutor PANIC RECOVER, err: %v", panicErr)
}
}()
diff --git a/backend/runner/taskrun/executor.go b/backend/runner/taskrun/executor.go
index 3bd74415c7..17795a4f0d 100644
--- a/backend/runner/taskrun/executor.go
+++ b/backend/runner/taskrun/executor.go
@@ -58,7 +58,7 @@ func RunExecutorOnce(ctx context.Context, driverCtx context.Context, exec Execut
slog.Error("TaskExecutor PANIC RECOVER", log.BBError(panicErr), log.BBStack("panic-stack"))
terminated = true
result = nil
- err = errors.Errorf("encounter internal error when executing task")
+ err = errors.Errorf("TaskExecutor PANIC RECOVER, err: %v", panicErr)
}
}()