Skip to content

Commit 437ecd4

Browse files
committed
fix(graph): rename _handle_agent_failure param incident→fallback (silence Sonar S1226 reassign-parameter bug)
1 parent a43be6d commit 437ecd4

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

dist/app.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,15 +1310,18 @@ def _handle_agent_failure(
13101310
exc: Exception,
13111311
inc_id: str,
13121312
store: "IncidentStore",
1313-
incident: "Incident",
1313+
fallback: "Incident",
13141314
) -> dict:
13151315
"""Reload incident (absorbing partial tool writes), stamp a failure AgentRun,
13161316
persist, and return the error state dict for the LangGraph node.
1317+
1318+
``fallback`` is the in-memory incident from the caller; we use it only
1319+
when the on-disk state has gone missing (FileNotFoundError on reload).
13171320
"""
13181321
try:
13191322
incident = store.load(inc_id)
13201323
except FileNotFoundError:
1321-
pass
1324+
incident = fallback
13221325
ended_at = datetime.now(timezone.utc).strftime(_UTC_TS_FMT)
13231326
incident.agents_run.append(AgentRun(
13241327
agent=skill_name, started_at=started_at, ended_at=ended_at,
@@ -1354,7 +1357,7 @@ async def node(state: GraphState) -> dict:
13541357
except Exception as exc: # noqa: BLE001
13551358
return _handle_agent_failure(
13561359
skill_name=skill.name, started_at=started_at, exc=exc,
1357-
inc_id=inc_id, store=store, incident=incident,
1360+
inc_id=inc_id, store=store, fallback=incident,
13581361
)
13591362

13601363
# Tools (e.g. update_incident) write straight to disk. Reload so the

src/orchestrator/graph.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,15 +279,18 @@ def _handle_agent_failure(
279279
exc: Exception,
280280
inc_id: str,
281281
store: "IncidentStore",
282-
incident: "Incident",
282+
fallback: "Incident",
283283
) -> dict:
284284
"""Reload incident (absorbing partial tool writes), stamp a failure AgentRun,
285285
persist, and return the error state dict for the LangGraph node.
286+
287+
``fallback`` is the in-memory incident from the caller; we use it only
288+
when the on-disk state has gone missing (FileNotFoundError on reload).
286289
"""
287290
try:
288291
incident = store.load(inc_id)
289292
except FileNotFoundError:
290-
pass
293+
incident = fallback
291294
ended_at = datetime.now(timezone.utc).strftime(_UTC_TS_FMT)
292295
incident.agents_run.append(AgentRun(
293296
agent=skill_name, started_at=started_at, ended_at=ended_at,
@@ -323,7 +326,7 @@ async def node(state: GraphState) -> dict:
323326
except Exception as exc: # noqa: BLE001
324327
return _handle_agent_failure(
325328
skill_name=skill.name, started_at=started_at, exc=exc,
326-
inc_id=inc_id, store=store, incident=incident,
329+
inc_id=inc_id, store=store, fallback=incident,
327330
)
328331

329332
# Tools (e.g. update_incident) write straight to disk. Reload so the

0 commit comments

Comments
 (0)