UAT: Action.validate_arguments silently accepts bool values for INTEGER type arguments due to Python's bool being a subclass of int #4023

Open
opened 2026-04-06 08:43:08 +00:00 by freemo · 0 comments
Owner

Metadata

  • Branch: fix/action-validate-arguments-bool-integer-check
  • Commit Message: fix(action): exclude bool from INTEGER type check in validate_arguments
  • Milestone: (none — backlog)
  • Parent Epic: #392

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

What Was Tested

Code-level analysis of src/cleveragents/domain/models/core/action.py, specifically the Action.validate_arguments method.

Expected Behavior (from spec)

When validating arguments for an action, passing a bool value (True or False) for an INTEGER type argument should be rejected with a validation error, since booleans and integers are distinct types in the specification's argument system.

Actual Behavior

The validate_arguments method in Action uses isinstance(value, int) to check for INTEGER type:

if arg.arg_type == ArgumentType.INTEGER:
    if not isinstance(value, int):
        errors.append(
            f"Argument {arg.name} must be an integer, got {type_name}"
        )

In Python, bool is a subclass of int, so isinstance(True, int) returns True. This means passing True or False as an INTEGER argument silently passes validation without any error.

Code Location

  • src/cleveragents/domain/models/core/action.py, Action.validate_arguments method

Steps to Reproduce

from cleveragents.domain.models.core.action import Action, ActionArgument, ArgumentType, ArgumentRequirement
from cleveragents.domain.models.core.plan import NamespacedName

action = Action(
    namespaced_name=NamespacedName.parse("local/test"),
    description="Test",
    definition_of_done="Done",
    strategy_actor="local/strategy",
    execution_actor="local/exec",
    arguments=[
        ActionArgument(
            name="count",
            arg_type=ArgumentType.INTEGER,
            requirement=ArgumentRequirement.REQUIRED,
        )
    ]
)

# This should fail but passes silently
errors = action.validate_arguments({"count": True})
print(errors)  # [] - empty, no errors!

Impact

  • Users can pass True/False as integer arguments without any error
  • This can lead to subtle bugs when the argument is used downstream (e.g., True is treated as 1, False as 0)
  • The type system's integrity is compromised

Subtasks

  • Add a failing Behave scenario in features/ that reproduces the bool-as-INTEGER silent acceptance
  • Fix Action.validate_arguments to explicitly exclude bool from the INTEGER type check
  • Verify the fix does not break existing INTEGER validation tests
  • Ensure all nox stages pass after the fix

Definition of Done

  • Action.validate_arguments({"count": True}) returns a non-empty errors list for an INTEGER argument
  • Action.validate_arguments({"count": False}) returns a non-empty errors list for an INTEGER argument
  • Action.validate_arguments({"count": 42}) continues to pass validation (no regression)
  • A Behave scenario covers the bool-as-INTEGER rejection case
  • All nox stages pass
  • Coverage >= 97%

Proposed Fix

if arg.arg_type == ArgumentType.INTEGER:
    if not isinstance(value, int) or isinstance(value, bool):
        errors.append(
            f"Argument {arg.name} must be an integer, got {type_name}"
        )

Automated by CleverAgents Bot
Supervisor: UAT Testing | Agent: ca-new-issue-creator

## Metadata - **Branch**: `fix/action-validate-arguments-bool-integer-check` - **Commit Message**: `fix(action): exclude bool from INTEGER type check in validate_arguments` - **Milestone**: *(none — backlog)* - **Parent Epic**: #392 > **Backlog note:** This issue was discovered during autonomous operation > on milestone v3.2.0. It does not block milestone completion and has been > placed in the backlog for human review and future milestone assignment. ## What Was Tested Code-level analysis of `src/cleveragents/domain/models/core/action.py`, specifically the `Action.validate_arguments` method. ## Expected Behavior (from spec) When validating arguments for an action, passing a `bool` value (`True` or `False`) for an `INTEGER` type argument should be rejected with a validation error, since booleans and integers are distinct types in the specification's argument system. ## Actual Behavior The `validate_arguments` method in `Action` uses `isinstance(value, int)` to check for INTEGER type: ```python if arg.arg_type == ArgumentType.INTEGER: if not isinstance(value, int): errors.append( f"Argument {arg.name} must be an integer, got {type_name}" ) ``` In Python, `bool` is a subclass of `int`, so `isinstance(True, int)` returns `True`. This means passing `True` or `False` as an INTEGER argument silently passes validation without any error. ## Code Location - `src/cleveragents/domain/models/core/action.py`, `Action.validate_arguments` method ## Steps to Reproduce ```python from cleveragents.domain.models.core.action import Action, ActionArgument, ArgumentType, ArgumentRequirement from cleveragents.domain.models.core.plan import NamespacedName action = Action( namespaced_name=NamespacedName.parse("local/test"), description="Test", definition_of_done="Done", strategy_actor="local/strategy", execution_actor="local/exec", arguments=[ ActionArgument( name="count", arg_type=ArgumentType.INTEGER, requirement=ArgumentRequirement.REQUIRED, ) ] ) # This should fail but passes silently errors = action.validate_arguments({"count": True}) print(errors) # [] - empty, no errors! ``` ## Impact - Users can pass `True`/`False` as integer arguments without any error - This can lead to subtle bugs when the argument is used downstream (e.g., `True` is treated as `1`, `False` as `0`) - The type system's integrity is compromised ## Subtasks - [ ] Add a failing Behave scenario in `features/` that reproduces the `bool`-as-INTEGER silent acceptance - [ ] Fix `Action.validate_arguments` to explicitly exclude `bool` from the INTEGER type check - [ ] Verify the fix does not break existing INTEGER validation tests - [ ] Ensure all nox stages pass after the fix ## Definition of Done - [ ] `Action.validate_arguments({"count": True})` returns a non-empty errors list for an INTEGER argument - [ ] `Action.validate_arguments({"count": False})` returns a non-empty errors list for an INTEGER argument - [ ] `Action.validate_arguments({"count": 42})` continues to pass validation (no regression) - [ ] A Behave scenario covers the `bool`-as-INTEGER rejection case - [ ] All nox stages pass - [ ] Coverage >= 97% ## Proposed Fix ```python if arg.arg_type == ArgumentType.INTEGER: if not isinstance(value, int) or isinstance(value, bool): errors.append( f"Argument {arg.name} must be an integer, got {type_name}" ) ``` --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: ca-new-issue-creator
HAL9000 added this to the v3.5.0 milestone 2026-04-09 03:11:57 +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#4023
No description provided.