Skip to content

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

fix(LSP): check nil pointer (#9217)

rebeliceda9dcae89cf4
diff --git a/backend/api/lsp/completion.go b/backend/api/lsp/completion.go
index ca11cb17ec..1137fe29f1 100644
--- a/backend/api/lsp/completion.go
+++ b/backend/api/lsp/completion.go
@@ -69,9 +69,15 @@ func (h *Handler) GetDatabaseMetadataFunc(ctx context.Context, databaseName stri
if err != nil {
return nil, errors.Wrap(err, "failed to get database")
}
+ if database == nil {
+ return nil, errors.Errorf("database %s for instance %s not found", databaseName, instanceID)
+ }
metadata, err := h.store.GetDBSchema(ctx, database.UID)
if err != nil {
return nil, errors.Wrap(err, "failed to get database schema")
}
+ if metadata == nil {
+ return nil, errors.Errorf("database %s schema for instance %s not found", databaseName, instanceID)
+ }
return metadata.GetDatabaseMetadata(), nil
}
diff --git a/backend/api/lsp/handler.go b/backend/api/lsp/handler.go
index f541b683fc..856ce6a705 100644
--- a/backend/api/lsp/handler.go
+++ b/backend/api/lsp/handler.go
@@ -110,6 +110,10 @@ func (h *Handler) getEngineType(ctx context.Context) storepb.Engine {
slog.Error("Failed to get instance", log.BBError(err))
return storepb.Engine_ENGINE_UNSPECIFIED
}
+ if instance == nil {
+ slog.Error("Instance not found", slog.String("instanceID", instanceID))
+ return storepb.Engine_ENGINE_UNSPECIFIED
+ }
return instance.Engine
}