Skip to content

Commit

Permalink
MAIN-1825 playbook bugfix holmes (#1484)
Browse files Browse the repository at this point in the history
* bugfix

params.context and params.resource is optional

* more holmes bugfix
  • Loading branch information
Avi-Robusta authored Jul 2, 2024
1 parent b84f753 commit 07ca9bb
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/robusta/core/playbooks/internal/ai_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def ask_holmes(event: ExecutionBaseEvent, params: AIInvestigateParams):
subject = params.resource.dict() if params.resource else {}
try:
holmes_req = HolmesRequest(
source=params.context.get("source", "unknown source"),
source=params.context.get("source", "unknown source") if params.context else "unknown source",
title=f"{investigation__title}",
subject=subject,
context=params.context if params.context else {},
Expand All @@ -44,19 +44,19 @@ def ask_holmes(event: ExecutionBaseEvent, params: AIInvestigateParams):
holmes_result = HolmesResult(**json.loads(result.text))
title_suffix = (
f" on {params.resource.name}"
if params.resource.name and params.resource.name.lower() != "unresolved"
if params.resource and params.resource.name and params.resource.name.lower() != "unresolved"
else ""
)

finding = Finding(
title=f"AI Analysis of {investigation__title}{title_suffix}",
aggregation_key="HolmesInvestigationResult",
subject=FindingSubject(
name=params.resource.name,
namespace=params.resource.namespace,
subject_type=FindingSubjectType.from_kind(params.resource.kind),
node=params.resource.node,
container=params.resource.container,
name=params.resource.name if params.resource else "",
namespace=params.resource.namespace if params.resource else "",
subject_type=FindingSubjectType.from_kind(params.resource.kind) if params.resource else FindingSubjectType.TYPE_NONE,
node=params.resource.node if params.resource else "",
container=params.resource.container if params.resource else "",
),
finding_type=FindingType.AI_ANALYSIS,
failure=False,
Expand Down

0 comments on commit 07ca9bb

Please sign in to comment.