Skip to content

Commit e1bac20

Browse files
vjeffreyclaude
andauthored
🐛 skip disabled AlloyDB API during GCP discovery (#7343)
cnspec scan gcp aborted with PermissionDenied when the AlloyDB API was not enabled in the project, because alloydb.clusters / instances / backups bubbled the raw gRPC error and discovery.go stops the scan on any discovery target error. AlloyDB was the one service in the Auto discovery set missing the skippable-error pattern that backupdr, batch, cloudbuild, dlp, eventarc, gke_backup and others already use. Guard each ListX iterator with isGRPCSkippable so disabled APIs, missing permissions, or NotFound locations degrade gracefully with a warning instead of failing the whole scan. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 7ebea62 commit e1bac20

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

providers/gcp/resources/alloydb.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111

1212
alloydb "cloud.google.com/go/alloydb/apiv1"
1313
"cloud.google.com/go/alloydb/apiv1/alloydbpb"
14+
"github.com/rs/zerolog/log"
1415
"go.mondoo.com/mql/v13/llx"
1516
"go.mondoo.com/mql/v13/providers-sdk/v1/plugin"
1617
"go.mondoo.com/mql/v13/providers-sdk/v1/util/convert"
@@ -82,6 +83,10 @@ func (g *mqlGcpProjectAlloydbService) clusters() ([]any, error) {
8283
break
8384
}
8485
if err != nil {
86+
if isGRPCSkippable(err) {
87+
log.Warn().Err(err).Msg("could not list AlloyDB clusters")
88+
return nil, nil
89+
}
8590
return nil, err
8691
}
8792

@@ -297,6 +302,10 @@ func (g *mqlGcpProjectAlloydbServiceCluster) instances() ([]any, error) {
297302
break
298303
}
299304
if err != nil {
305+
if isGRPCSkippable(err) {
306+
log.Warn().Err(err).Msg("could not list AlloyDB instances")
307+
return nil, nil
308+
}
300309
return nil, err
301310
}
302311

@@ -437,6 +446,10 @@ func (g *mqlGcpProjectAlloydbServiceCluster) backups() ([]any, error) {
437446
break
438447
}
439448
if err != nil {
449+
if isGRPCSkippable(err) {
450+
log.Warn().Err(err).Msg("could not list AlloyDB backups")
451+
return nil, nil
452+
}
440453
return nil, err
441454
}
442455

0 commit comments

Comments
 (0)