BUG-HUNT: [type-safety] Potential TypeError in _canonical_blob #3291

Open
opened 2026-04-05 09:12:10 +00:00 by freemo · 0 comments
Owner

Metadata

  • Branch: fix/actor-registry/canonical-blob-none-guard
  • Commit Message: fix(actor): guard _canonical_blob against None raw_blob to prevent TypeError
  • Milestone: N/A (Backlog — see note below)
  • Parent Epic: #392

Background and Context

The _canonical_blob method in ActorRegistry accepts an optional raw_blob argument typed as dict[str, Any] | None. The original implementation passes raw_blob directly to dict() without a None guard, which will raise a TypeError at runtime if raw_blob is None. This is a type-safety defect in the Actor registry layer.

Current Behavior

When _canonical_blob is called with raw_blob=None, the line:

blob: dict[str, Any] = dict(raw_blob)

raises:

TypeError: 'NoneType' object is not iterable

causing the program to crash.

Expected Behavior

The method should handle raw_blob=None gracefully — either falling back to dict(config.options) or returning an empty dict {}, without raising a TypeError.

Suggested Fix

blob: dict[str, Any] = dict(raw_blob) if raw_blob is not None else {}

Or, if falling back to config options is the intended behaviour:

blob: dict[str, Any] = dict(raw_blob) if raw_blob is not None else dict(config.options)

Evidence

  • File: src/cleveragents/actor/registry.py
  • Function/Class: ActorRegistry._canonical_blob
  • Line: 103
  • Severity: Medium — crash on None input; likelihood depends on call-site discipline
  • Category: type-safety

Subtasks

  • Confirm current code at line 103 of src/cleveragents/actor/registry.py is missing the None guard
  • Add None guard: dict(raw_blob) if raw_blob is not None else {} (or fallback to config.options per design intent)
  • Tests (Behave): Add scenario for _canonical_blob called with raw_blob=None
  • Tests (Robot): Add integration test covering the None path through ActorRegistry
  • Verify coverage >= 97% via nox -s coverage_report
  • Run nox (all default sessions), fix any errors

Definition of Done

  • All subtasks above are completed and checked off
  • A Git commit is created where the first line of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation
  • The commit is pushed to the remote on the branch matching the Branch in Metadata exactly
  • The commit is submitted as a pull request to master, reviewed, and merged before this issue is marked done
  • All nox stages pass
  • Coverage >= 97%

Backlog note: This issue was discovered during autonomous operation
on milestone v3.7.0. It does not block milestone completion and has been
placed in the backlog for human review and future milestone assignment.


Automated by CleverAgents Bot
Supervisor: Bug Hunting | Agent: ca-new-issue-creator

## Metadata - **Branch**: `fix/actor-registry/canonical-blob-none-guard` - **Commit Message**: `fix(actor): guard _canonical_blob against None raw_blob to prevent TypeError` - **Milestone**: N/A (Backlog — see note below) - **Parent Epic**: #392 ## Background and Context The `_canonical_blob` method in `ActorRegistry` accepts an optional `raw_blob` argument typed as `dict[str, Any] | None`. The original implementation passes `raw_blob` directly to `dict()` without a `None` guard, which will raise a `TypeError` at runtime if `raw_blob` is `None`. This is a type-safety defect in the Actor registry layer. ## Current Behavior When `_canonical_blob` is called with `raw_blob=None`, the line: ```python blob: dict[str, Any] = dict(raw_blob) ``` raises: ``` TypeError: 'NoneType' object is not iterable ``` causing the program to crash. ## Expected Behavior The method should handle `raw_blob=None` gracefully — either falling back to `dict(config.options)` or returning an empty dict `{}`, without raising a `TypeError`. ## Suggested Fix ```python blob: dict[str, Any] = dict(raw_blob) if raw_blob is not None else {} ``` Or, if falling back to config options is the intended behaviour: ```python blob: dict[str, Any] = dict(raw_blob) if raw_blob is not None else dict(config.options) ``` ## Evidence - **File**: `src/cleveragents/actor/registry.py` - **Function/Class**: `ActorRegistry._canonical_blob` - **Line**: 103 - **Severity**: Medium — crash on `None` input; likelihood depends on call-site discipline - **Category**: type-safety ## Subtasks - [ ] Confirm current code at line 103 of `src/cleveragents/actor/registry.py` is missing the `None` guard - [ ] Add `None` guard: `dict(raw_blob) if raw_blob is not None else {}` (or fallback to `config.options` per design intent) - [ ] Tests (Behave): Add scenario for `_canonical_blob` called with `raw_blob=None` - [ ] Tests (Robot): Add integration test covering the `None` path through `ActorRegistry` - [ ] Verify coverage >= 97% via `nox -s coverage_report` - [ ] Run `nox` (all default sessions), fix any errors ## Definition of Done - [ ] All subtasks above are completed and checked off - [ ] A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation - [ ] The commit is pushed to the remote on the branch matching the **Branch** in Metadata exactly - [ ] The commit is submitted as a **pull request** to `master`, reviewed, and **merged** before this issue is marked done - [ ] All nox stages pass - [ ] Coverage >= 97% > **Backlog note:** This issue was discovered during autonomous operation > on milestone v3.7.0. It does not block milestone completion and has been > placed in the backlog for human review and future milestone assignment. --- **Automated by CleverAgents Bot** Supervisor: Bug Hunting | Agent: ca-new-issue-creator
freemo added this to the v3.7.0 milestone 2026-04-05 09:32:59 +00:00
freemo modified the milestone from v3.7.0 to v3.8.0 2026-04-05 09:33:58 +00:00
freemo removed this from the v3.8.0 milestone 2026-04-07 00:10:14 +00:00
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.

Blocks
#392 Epic: Actor YAML & Compiler
cleveragents/cleveragents-core
Reference
cleveragents/cleveragents-core#3291
No description provided.