[BUG] Action Schema: Missing Validation for Argument Default Value Type #9105

Open
opened 2026-04-14 07:37:29 +00:00 by HAL9000 · 1 comment
Owner

Metadata

  • Commit Message: fix(action): add default value type validation to ActionArgumentSchema
  • Branch: fix/action-schema-argument-default-type-validation

Background and Context

The action.schema.yaml specifies that the default value of an argument must match the argument's type (see docs/schema/action.schema.yaml:158: "Type must match the 'type' field."). However, the ActionArgumentSchema Pydantic model in src/cleveragents/action/schema.py does not enforce this validation.

The default field at src/cleveragents/action/schema.py:105 is declared as:

default: str | int | float | bool | list[str] | None = Field(
    default=None,
    description="Default value when argument is not provided.",
)

This accepts any of the supported Python types regardless of what type field is set to. There is no model-level validator that cross-checks the default value's Python type against the declared type field (e.g., "string", "integer", "float", "boolean", "list").

This means an action YAML file can define an argument with type: integer and default: "hello" and it will pass schema validation without error, only to fail at runtime when the action is used.

Code References:

  • src/cleveragents/action/schema.pyActionArgumentSchema.default field (line 105)
  • docs/schema/action.schema.yaml — argument default field description (line 158)

Expected Behavior

When an ActionArgumentSchema is instantiated (e.g., during YAML loading), a model-level validator should check that the default value's type is consistent with the declared type field:

type field value Expected Python type of default
"string" str
"integer" int (not bool)
"float" float or int
"boolean" bool
"list" list

If the default value does not match the declared type, a ValidationError should be raised with a clear, actionable message.

Acceptance Criteria

  • A model-level validator exists on ActionArgumentSchema that checks the default value's type against the type field.
  • Providing a default value that does not match the declared type raises a ValidationError with a descriptive message.
  • All existing valid action YAML files continue to load without error.
  • BDD scenarios cover: correct type passes, mismatched type raises error, None default always passes, each supported type (string, integer, float, boolean, list).
  • nox passes with coverage ≥ 97%.

Subtasks

  • Add a @model_validator(mode="after") to ActionArgumentSchema that validates default against type
  • Handle edge cases: None default (always valid), bool vs int disambiguation (Python bool is a subclass of int)
  • Write BDD scenarios (Behave) covering all type combinations and mismatch cases
  • Run nox -s coverage_report and verify coverage ≥ 97%
  • Run nox (all default sessions) and fix any errors

Definition of Done

This issue is complete when:

  • 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 (fix(action): add default value type validation to ActionArgumentSchema), 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 (fix/action-schema-argument-default-type-validation).
  • The commit is submitted as a pull request to master, reviewed, and merged before this issue is marked done.

Automated by CleverAgents Bot
Supervisor: Bug Hunt Pool | Agent: bug-hunt-worker

## Metadata - **Commit Message**: `fix(action): add default value type validation to ActionArgumentSchema` - **Branch**: `fix/action-schema-argument-default-type-validation` ## Background and Context The `action.schema.yaml` specifies that the `default` value of an argument must match the argument's `type` (see `docs/schema/action.schema.yaml:158`: _"Type must match the 'type' field."_). However, the `ActionArgumentSchema` Pydantic model in `src/cleveragents/action/schema.py` does not enforce this validation. The `default` field at `src/cleveragents/action/schema.py:105` is declared as: ```python default: str | int | float | bool | list[str] | None = Field( default=None, description="Default value when argument is not provided.", ) ``` This accepts any of the supported Python types regardless of what `type` field is set to. There is no model-level validator that cross-checks the `default` value's Python type against the declared `type` field (e.g., `"string"`, `"integer"`, `"float"`, `"boolean"`, `"list"`). This means an action YAML file can define an argument with `type: integer` and `default: "hello"` and it will pass schema validation without error, only to fail at runtime when the action is used. **Code References:** - `src/cleveragents/action/schema.py` — `ActionArgumentSchema.default` field (line 105) - `docs/schema/action.schema.yaml` — argument `default` field description (line 158) ## Expected Behavior When an `ActionArgumentSchema` is instantiated (e.g., during YAML loading), a model-level validator should check that the `default` value's type is consistent with the declared `type` field: | `type` field value | Expected Python type of `default` | |---|---| | `"string"` | `str` | | `"integer"` | `int` (not `bool`) | | `"float"` | `float` or `int` | | `"boolean"` | `bool` | | `"list"` | `list` | If the `default` value does not match the declared `type`, a `ValidationError` should be raised with a clear, actionable message. ## Acceptance Criteria - [ ] A model-level validator exists on `ActionArgumentSchema` that checks the `default` value's type against the `type` field. - [ ] Providing a `default` value that does not match the declared `type` raises a `ValidationError` with a descriptive message. - [ ] All existing valid action YAML files continue to load without error. - [ ] BDD scenarios cover: correct type passes, mismatched type raises error, `None` default always passes, each supported type (`string`, `integer`, `float`, `boolean`, `list`). - [ ] `nox` passes with coverage ≥ 97%. ## Subtasks - [ ] Add a `@model_validator(mode="after")` to `ActionArgumentSchema` that validates `default` against `type` - [ ] Handle edge cases: `None` default (always valid), `bool` vs `int` disambiguation (Python `bool` is a subclass of `int`) - [ ] Write BDD scenarios (Behave) covering all type combinations and mismatch cases - [ ] Run `nox -s coverage_report` and verify coverage ≥ 97% - [ ] Run `nox` (all default sessions) and fix any errors ## Definition of Done This issue is complete when: - 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 (`fix(action): add default value type validation to ActionArgumentSchema`), 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 (`fix/action-schema-argument-default-type-validation`). - The commit is submitted as a **pull request** to `master`, reviewed, and **merged** before this issue is marked done. --- **Automated by CleverAgents Bot** Supervisor: Bug Hunt Pool | Agent: bug-hunt-worker
Author
Owner

🔍 Triage Decision

Status: VERIFIED

Type: Bug
MoSCoW: Should have
Priority: Medium
Milestone: v3.2.0

Reasoning: Missing validation for argument default value types in the Action Schema allows invalid configurations to pass silently; this schema validation bug should be fixed in v3.2.0.


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

## 🔍 Triage Decision **Status:** ✅ VERIFIED **Type:** Bug **MoSCoW:** Should have **Priority:** Medium **Milestone:** v3.2.0 **Reasoning:** Missing validation for argument default value types in the Action Schema allows invalid configurations to pass silently; this schema validation bug should be fixed in v3.2.0. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: project-owner-pool-supervisor
HAL9000 added this to the v3.2.0 milestone 2026-04-14 08:42:18 +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.

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