fix: remove None databases name for removing provider Neo4j databases (#9860)

Co-authored-by: Josema Camacho <josema@prowler.com>
Co-authored-by: Pepe Fagoaga <pepe@prowler.com>
This commit is contained in:
Prowler Bot
2026-01-22 15:31:08 +01:00
committed by GitHub
parent be1909f752
commit 0b6352b32e
2 changed files with 12 additions and 4 deletions

View File

@@ -66,6 +66,7 @@ class RetryableSession:
except (
neo4j.exceptions.ServiceUnavailable,
ConnectionResetError,
BrokenPipeError,
) as exc: # pragma: no cover - depends on infra
last_exc = exc
attempt += 1

View File

@@ -1,6 +1,7 @@
from datetime import datetime, timezone
from typing import Any
from django.db.models import Q
from cartography.config import Config as CartographyConfig
from api.db_utils import rls_transaction
@@ -153,9 +154,15 @@ def get_provider_graph_database_names(tenant_id: str, provider_id: str) -> list[
Note: For accesing the `AttackPathsScan` we need to use `all_objects` manager because the provider is soft-deleted.
"""
with rls_transaction(tenant_id):
graph_databases_names_qs = ProwlerAPIAttackPathsScan.all_objects.filter(
provider_id=provider_id,
is_graph_database_deleted=False,
).values_list("graph_database", flat=True)
graph_databases_names_qs = (
ProwlerAPIAttackPathsScan.all_objects.filter(
~Q(graph_database=""),
graph_database__isnull=False,
provider_id=provider_id,
is_graph_database_deleted=False,
)
.values_list("graph_database", flat=True)
.distinct()
)
return list(graph_databases_names_qs)