Argument 'default' Type Not Enforced in Action Schema #8191

Open
opened 2026-04-13 04:23:09 +00:00 by HAL9000 · 1 comment
Owner

Metadata

  • Commit Message: fix(action): enforce compatible default type for action arguments
  • Branch Name: bugfix/action-default-type-validation

Background and Context

The ActionArgumentSchema in src/cleveragents/action/schema.py allows defining a default value for an action argument. The type of this default value should match the type specified for the argument.

Currently, ActionArgumentSchema does not validate that the type of the default value is compatible with the specified type. For example, it is possible to provide a string default for an integer type, which can lead to runtime errors downstream when the default value is actually used.

Steps to Reproduce:

from cleveragents.action.schema import ActionArgumentSchema

ActionArgumentSchema(name="threshold", type="integer", default="ten")

This code currently validates successfully, but it should raise a ValueError.

Expected Behavior

The ActionArgumentSchema should validate that the type of the default value is compatible with the specified type field. A mismatched default type (e.g., a string default for an integer argument) should raise a ValueError at schema construction time, preventing silent runtime failures.

Acceptance Criteria

  • A validator is added to ActionArgumentSchema that checks the type of the default value against the type field.
  • The validator handles type coercion for numeric types where appropriate (e.g., int coercible from numeric strings may be allowed, but non-numeric strings for integer types must be rejected).
  • Unit tests are added to verify that mismatched default types are correctly rejected.
  • Existing tests continue to pass with no regressions.

Subtasks

  • Investigate the current ActionArgumentSchema implementation in src/cleveragents/action/schema.py to understand the existing validation structure.
  • Design and implement a Pydantic validator (or equivalent) that enforces default value type compatibility with the type field.
  • Handle edge cases: None defaults, optional arguments, and numeric type coercion rules.
  • Write unit tests covering:
    • Valid default values (matching types)
    • Invalid default values (mismatched types, e.g., string for integer)
    • Edge cases (None, numeric coercion boundaries)
  • Run the full test suite to confirm no regressions.
  • Update any relevant documentation or docstrings.

Definition of Done

This issue should be closed when:

  1. A validator enforcing default value type compatibility is merged into ActionArgumentSchema.
  2. All acceptance criteria above are met and verified by passing tests.
  3. The fix is covered by unit tests with no regressions in the existing test suite.
  4. The PR is reviewed, approved, and merged into the target branch.

Automated by CleverAgents Bot
Agent: new-issue-creator

## Metadata - **Commit Message:** `fix(action): enforce compatible default type for action arguments` - **Branch Name:** `bugfix/action-default-type-validation` ## Background and Context The `ActionArgumentSchema` in `src/cleveragents/action/schema.py` allows defining a `default` value for an action argument. The type of this default value should match the `type` specified for the argument. Currently, `ActionArgumentSchema` does not validate that the type of the `default` value is compatible with the specified `type`. For example, it is possible to provide a string default for an integer type, which can lead to runtime errors downstream when the default value is actually used. **Steps to Reproduce:** ```python from cleveragents.action.schema import ActionArgumentSchema ActionArgumentSchema(name="threshold", type="integer", default="ten") ``` This code currently validates successfully, but it should raise a `ValueError`. ## Expected Behavior The `ActionArgumentSchema` should validate that the type of the `default` value is compatible with the specified `type` field. A mismatched default type (e.g., a string default for an integer argument) should raise a `ValueError` at schema construction time, preventing silent runtime failures. ## Acceptance Criteria - [ ] A validator is added to `ActionArgumentSchema` that checks the type of the `default` value against the `type` field. - [ ] The validator handles type coercion for numeric types where appropriate (e.g., `int` coercible from numeric strings may be allowed, but non-numeric strings for integer types must be rejected). - [ ] Unit tests are added to verify that mismatched default types are correctly rejected. - [ ] Existing tests continue to pass with no regressions. ## Subtasks - [ ] Investigate the current `ActionArgumentSchema` implementation in `src/cleveragents/action/schema.py` to understand the existing validation structure. - [ ] Design and implement a Pydantic validator (or equivalent) that enforces `default` value type compatibility with the `type` field. - [ ] Handle edge cases: `None` defaults, optional arguments, and numeric type coercion rules. - [ ] Write unit tests covering: - Valid default values (matching types) - Invalid default values (mismatched types, e.g., string for integer) - Edge cases (None, numeric coercion boundaries) - [ ] Run the full test suite to confirm no regressions. - [ ] Update any relevant documentation or docstrings. ## Definition of Done This issue should be closed when: 1. A validator enforcing `default` value type compatibility is merged into `ActionArgumentSchema`. 2. All acceptance criteria above are met and verified by passing tests. 3. The fix is covered by unit tests with no regressions in the existing test suite. 4. The PR is reviewed, approved, and merged into the target branch. --- **Automated by CleverAgents Bot** Agent: new-issue-creator
HAL9000 added this to the v3.2.0 milestone 2026-04-13 04:54:43 +00:00
Author
Owner

Verified — Type enforcement for action argument defaults prevents silent runtime failures. This is a real bug that could cause confusing errors downstream. Should Have fix — important for correctness but not blocking core functionality. Assigning to v3.2.0 as it's an action schema issue. Verified.


Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: project-owner-pool-supervisor

✅ **Verified** — Type enforcement for action argument defaults prevents silent runtime failures. This is a real bug that could cause confusing errors downstream. **Should Have** fix — important for correctness but not blocking core functionality. Assigning to v3.2.0 as it's an action schema issue. Verified. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: project-owner-pool-supervisor
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#8191
No description provided.