UAT: ActionArgumentSchema.validate_name allows hyphenated argument names but BDD spec test expects them to be rejected — schema and test are contradictory #3000

Open
opened 2026-04-05 03:27:03 +00:00 by freemo · 1 comment
Owner

Metadata

  • Branch: fix/action-argument-schema-reject-hyphenated-names
  • Commit Message: fix(action): reject hyphenated argument names in ActionArgumentSchema.validate_name
  • Milestone: v3.7.0
  • Parent Epic: #392

Bug Report

Feature Area: Action Configuration — ActionArgumentSchema name validation
Spec Reference: Argument names must be valid Python identifiers (used as CLI keys and template variables such as ${my_arg})

Description

There is a contradiction between the ActionArgumentSchema implementation and the BDD test specification regarding hyphenated argument names.

In src/cleveragents/action/schema.py, the validate_name method uses:

if not v.replace("-", "_").isidentifier():
    raise ValueError(...)

This logic replaces hyphens with underscores before checking isidentifier(), which means hyphenated names like my-arg are accepted by the schema validator.

In features/consolidated_action.feature, there is an explicit BDD scenario:

Scenario: Invalid argument name with hyphen raises error
  When I try to create an action argument with invalid name "invalid-name"
  Then a validation error should be raised
  And the error should mention "Argument name must be a valid Python identifier"

This test expects hyphenated names to be REJECTED.

These two behaviors are contradictory. The BDD test (which represents the spec-aligned behavior) says hyphens should be invalid. The implementation allows them.

The spec-correct behavior is that argument names should be valid Python identifiers (no hyphens), since they are used as --arg name=value CLI keys and must be usable as identifiers in template rendering (e.g., ${my_arg}).

Expected Behavior (per BDD spec)

  • Argument name "invalid-name" should raise a ValidationError mentioning "valid Python identifier"

Actual Behavior

  • ActionArgumentSchema(name="invalid-name", type="string") succeeds without error because "invalid-name".replace("-", "_").isidentifier() returns True

Code Location

src/cleveragents/action/schema.pyActionArgumentSchema.validate_name method

Steps to Reproduce

  1. Instantiate ActionArgumentSchema(name="my-arg", type="string")
  2. Observe that no ValidationError is raised
  3. Compare with BDD test scenario "Invalid argument name with hyphen raises error" which expects rejection

Subtasks

  • Locate ActionArgumentSchema.validate_name in src/cleveragents/action/schema.py
  • Remove the .replace("-", "_") call so that hyphenated names fail the isidentifier() check directly
  • Verify the error message still mentions "Argument name must be a valid Python identifier"
  • Confirm the BDD scenario "Invalid argument name with hyphen raises error" in features/consolidated_action.feature now passes
  • Audit for any other callers or tests that rely on the old (permissive) behaviour and update them
  • Run nox -e lint, nox -e typecheck, nox -e unit_tests, and nox -e coverage_report — all must pass

Definition of Done

  • ActionArgumentSchema(name="invalid-name", type="string") raises ValidationError mentioning "valid Python identifier"
  • ActionArgumentSchema(name="valid_name", type="string") continues to succeed
  • BDD scenario "Invalid argument name with hyphen raises error" passes without modification
  • No regression in any other ActionArgumentSchema name-validation scenarios
  • All nox stages pass
  • Coverage >= 97%

Automated by CleverAgents Bot
Supervisor: UAT Testing | Agent: ca-uat-tester

## Metadata - **Branch**: `fix/action-argument-schema-reject-hyphenated-names` - **Commit Message**: `fix(action): reject hyphenated argument names in ActionArgumentSchema.validate_name` - **Milestone**: v3.7.0 - **Parent Epic**: #392 ## Bug Report **Feature Area:** Action Configuration — `ActionArgumentSchema` name validation **Spec Reference:** Argument names must be valid Python identifiers (used as CLI keys and template variables such as `${my_arg}`) ### Description There is a contradiction between the `ActionArgumentSchema` implementation and the BDD test specification regarding hyphenated argument names. **In `src/cleveragents/action/schema.py`**, the `validate_name` method uses: ```python if not v.replace("-", "_").isidentifier(): raise ValueError(...) ``` This logic replaces hyphens with underscores before checking `isidentifier()`, which means **hyphenated names like `my-arg` are accepted** by the schema validator. **In `features/consolidated_action.feature`**, there is an explicit BDD scenario: ```gherkin Scenario: Invalid argument name with hyphen raises error When I try to create an action argument with invalid name "invalid-name" Then a validation error should be raised And the error should mention "Argument name must be a valid Python identifier" ``` This test **expects hyphenated names to be REJECTED**. These two behaviors are contradictory. The BDD test (which represents the spec-aligned behavior) says hyphens should be invalid. The implementation allows them. The spec-correct behavior is that argument names should be valid Python identifiers (no hyphens), since they are used as `--arg name=value` CLI keys and must be usable as identifiers in template rendering (e.g., `${my_arg}`). ### Expected Behavior (per BDD spec) - Argument name `"invalid-name"` should raise a `ValidationError` mentioning "valid Python identifier" ### Actual Behavior - `ActionArgumentSchema(name="invalid-name", type="string")` succeeds without error because `"invalid-name".replace("-", "_").isidentifier()` returns `True` ### Code Location `src/cleveragents/action/schema.py` — `ActionArgumentSchema.validate_name` method ### Steps to Reproduce 1. Instantiate `ActionArgumentSchema(name="my-arg", type="string")` 2. Observe that no `ValidationError` is raised 3. Compare with BDD test scenario "Invalid argument name with hyphen raises error" which expects rejection ## Subtasks - [ ] Locate `ActionArgumentSchema.validate_name` in `src/cleveragents/action/schema.py` - [ ] Remove the `.replace("-", "_")` call so that hyphenated names fail the `isidentifier()` check directly - [ ] Verify the error message still mentions "Argument name must be a valid Python identifier" - [ ] Confirm the BDD scenario "Invalid argument name with hyphen raises error" in `features/consolidated_action.feature` now passes - [ ] Audit for any other callers or tests that rely on the old (permissive) behaviour and update them - [ ] Run `nox -e lint`, `nox -e typecheck`, `nox -e unit_tests`, and `nox -e coverage_report` — all must pass ## Definition of Done - [ ] `ActionArgumentSchema(name="invalid-name", type="string")` raises `ValidationError` mentioning "valid Python identifier" - [ ] `ActionArgumentSchema(name="valid_name", type="string")` continues to succeed - [ ] BDD scenario "Invalid argument name with hyphen raises error" passes without modification - [ ] No regression in any other `ActionArgumentSchema` name-validation scenarios - [ ] All nox stages pass - [ ] Coverage >= 97% --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: ca-uat-tester
freemo added this to the v3.7.0 milestone 2026-04-05 03:27:50 +00:00
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • Priority: Confirmed
  • MoSCoW: Should Have

Valid finding verified during batch triage.


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

Issue triaged by project owner: - **State**: Verified - **Priority**: Confirmed - **MoSCoW**: Should Have Valid finding verified during batch triage. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: ca-project-owner
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#3000
No description provided.