Align from_blob() graph_descriptor resolution to use is not None checks instead of or #10831

Open
opened 2026-04-23 04:03:11 +00:00 by hurui200320 · 0 comments
Member

Metadata

  • Milestone: v3.5.0
  • Parent Epic: (Actor Configuration)
  • Branch: bugfix/m6-from-blob-graph-resolution-or-vs-is-not-none
  • Commit Message: fix(actor): align from_blob() graph_descriptor resolution with add()

Description

ActorConfiguration.from_blob() uses Python's or operator for graph_descriptor resolution:

resolved_graph = (
    graph_descriptor
    or data.get("graph_descriptor")
    or data.get("graph")
    or v2_graph
)

This causes an empty dict {} passed as graph_descriptor to silently fall through to the next alternative because {} or ... evaluates the right operand. In contrast, registry.add() correctly uses explicit is not None checks:

top_graph = top_graph_raw if top_graph_raw is not None else blob.get("graph")
resolved_graph = top_graph if top_graph is not None else nested_graph

The add() approach is correct — an empty dict {} is a valid (though degenerate) graph descriptor and should be preserved, not silently overwritten. This inconsistency was identified during code review of PR #10796 (review item M2 by @CoreRasurae).

Subtasks

  • Update from_blob() to use explicit is not None checks for graph_descriptor, data.get("graph_descriptor"), data.get("graph"), and v2_graph resolution
  • Add Behave scenarios verifying that from_blob() preserves an empty dict {} as graph_descriptor
  • Verify all existing tests still pass

Definition of Done

  • from_blob() uses is not None checks instead of or for graph resolution
  • Behave test covers the graph_descriptor={} edge case
  • All quality gates pass (nox -e lint, nox -e typecheck, nox -e unit_tests, nox -e integration_tests, nox -e coverage_report >= 97%)
## Metadata - **Milestone**: v3.5.0 - **Parent Epic**: *(Actor Configuration)* - **Branch**: `bugfix/m6-from-blob-graph-resolution-or-vs-is-not-none` - **Commit Message**: `fix(actor): align from_blob() graph_descriptor resolution with add()` ## Description `ActorConfiguration.from_blob()` uses Python's `or` operator for `graph_descriptor` resolution: ```python resolved_graph = ( graph_descriptor or data.get("graph_descriptor") or data.get("graph") or v2_graph ) ``` This causes an empty dict `{}` passed as `graph_descriptor` to silently fall through to the next alternative because `{} or ...` evaluates the right operand. In contrast, `registry.add()` correctly uses explicit `is not None` checks: ```python top_graph = top_graph_raw if top_graph_raw is not None else blob.get("graph") resolved_graph = top_graph if top_graph is not None else nested_graph ``` The `add()` approach is correct — an empty dict `{}` is a valid (though degenerate) graph descriptor and should be preserved, not silently overwritten. This inconsistency was identified during code review of PR #10796 (review item M2 by @CoreRasurae). ## Subtasks - [ ] Update `from_blob()` to use explicit `is not None` checks for `graph_descriptor`, `data.get("graph_descriptor")`, `data.get("graph")`, and `v2_graph` resolution - [ ] Add Behave scenarios verifying that `from_blob()` preserves an empty dict `{}` as `graph_descriptor` - [ ] Verify all existing tests still pass ## Definition of Done - `from_blob()` uses `is not None` checks instead of `or` for graph resolution - Behave test covers the `graph_descriptor={}` edge case - All quality gates pass (`nox -e lint`, `nox -e typecheck`, `nox -e unit_tests`, `nox -e integration_tests`, `nox -e coverage_report` >= 97%)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cleveragents/cleveragents-core#10831
No description provided.