UAT: ActionArgumentSchema.validate_name error message says "or hyphens" are allowed but BDD test expects hyphens to be invalid — misleading error message contradicts spec behavior #3039

Open
opened 2026-04-05 04:12:58 +00:00 by freemo · 3 comments
Owner

Metadata

  • Branch: fix/action-argument-schema/misleading-error-message
  • Commit Message: fix(action/schema): correct validate_name error message to say "valid Python identifier" and remove "or hyphens" claim
  • Milestone: v3.7.0
  • Parent Epic: #392

Bug Report

Feature Area: Action Configuration — ActionArgumentSchema.validate_name error message
Spec Reference: Argument names must be valid Python identifiers; BDD scenario in features/consolidated_action.feature defines the expected error message text

Description

The ActionArgumentSchema.validate_name method in src/cleveragents/action/schema.py raises a ValueError with a misleading message when an invalid argument name is provided:

raise ValueError(
    f"Argument name '{v}' is not a valid identifier. "
    "Use alphanumeric characters, underscores, or hyphens."
)

The error message explicitly says "or hyphens" are allowed. However, the BDD test in features/consolidated_action.feature has the 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 reveals two issues:

  1. The error message says hyphens are allowed ("or hyphens"), but the BDD test expects hyphens to be INVALID
  2. The BDD test expects the error to mention "Argument name must be a valid Python identifier" but the actual error says "is not a valid identifier"

The error message is misleading and contradicts the expected behavior defined in the BDD tests. Users who see "Use alphanumeric characters, underscores, or hyphens" will incorrectly believe hyphens are valid argument names.

Note: The root cause of hyphens being accepted or rejected is tracked separately in #3000. This issue focuses exclusively on correcting the error message text to match the BDD specification.

Expected Behavior (per BDD spec)

  • Error message should say something like "Argument name must be a valid Python identifier"
  • Error message should NOT suggest hyphens are valid

Actual Behavior

  • Error message says "Use alphanumeric characters, underscores, or hyphens" — incorrectly implying hyphens are valid
  • Error message text doesn't match what the BDD test expects ("must be a valid Python identifier")

Code Location

src/cleveragents/action/schema.pyActionArgumentSchema.validate_name method, raise ValueError(...) line

Subtasks

  • Locate ActionArgumentSchema.validate_name in src/cleveragents/action/schema.py
  • Update the raise ValueError(...) message to say "Argument name must be a valid Python identifier" (matching the BDD scenario assertion exactly)
  • Remove the phrase "or hyphens" from the error message so it no longer implies hyphens are valid
  • Verify the BDD scenario "Invalid argument name with hyphen raises error" in features/consolidated_action.feature now passes (the And the error should mention "Argument name must be a valid Python identifier" step)
  • Search for any other tests or code that assert on the old error message text 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.validate_name raises an error whose message contains "Argument name must be a valid Python identifier"
  • The error message no longer contains the phrase "or hyphens"
  • BDD scenario "Invalid argument name with hyphen raises error" passes without modification to the feature file
  • 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/misleading-error-message` - **Commit Message**: `fix(action/schema): correct validate_name error message to say "valid Python identifier" and remove "or hyphens" claim` - **Milestone**: v3.7.0 - **Parent Epic**: #392 ## Bug Report **Feature Area:** Action Configuration — `ActionArgumentSchema.validate_name` error message **Spec Reference:** Argument names must be valid Python identifiers; BDD scenario in `features/consolidated_action.feature` defines the expected error message text ### Description The `ActionArgumentSchema.validate_name` method in `src/cleveragents/action/schema.py` raises a `ValueError` with a misleading message when an invalid argument name is provided: ```python raise ValueError( f"Argument name '{v}' is not a valid identifier. " "Use alphanumeric characters, underscores, or hyphens." ) ``` The error message explicitly says **"or hyphens"** are allowed. However, the BDD test in `features/consolidated_action.feature` has the 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 reveals two issues: 1. The error message says hyphens are allowed ("or hyphens"), but the BDD test expects hyphens to be **INVALID** 2. The BDD test expects the error to mention `"Argument name must be a valid Python identifier"` but the actual error says `"is not a valid identifier"` The error message is misleading and contradicts the expected behavior defined in the BDD tests. Users who see "Use alphanumeric characters, underscores, or hyphens" will incorrectly believe hyphens are valid argument names. **Note:** The root cause of hyphens being accepted or rejected is tracked separately in #3000. This issue focuses exclusively on correcting the error message text to match the BDD specification. ### Expected Behavior (per BDD spec) - Error message should say something like `"Argument name must be a valid Python identifier"` - Error message should **NOT** suggest hyphens are valid ### Actual Behavior - Error message says `"Use alphanumeric characters, underscores, or hyphens"` — incorrectly implying hyphens are valid - Error message text doesn't match what the BDD test expects (`"must be a valid Python identifier"`) ### Code Location `src/cleveragents/action/schema.py` — `ActionArgumentSchema.validate_name` method, `raise ValueError(...)` line ## Subtasks - [ ] Locate `ActionArgumentSchema.validate_name` in `src/cleveragents/action/schema.py` - [ ] Update the `raise ValueError(...)` message to say `"Argument name must be a valid Python identifier"` (matching the BDD scenario assertion exactly) - [ ] Remove the phrase "or hyphens" from the error message so it no longer implies hyphens are valid - [ ] Verify the BDD scenario `"Invalid argument name with hyphen raises error"` in `features/consolidated_action.feature` now passes (the `And the error should mention "Argument name must be a valid Python identifier"` step) - [ ] Search for any other tests or code that assert on the old error message text 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.validate_name` raises an error whose message contains `"Argument name must be a valid Python identifier"` - [ ] The error message no longer contains the phrase "or hyphens" - [ ] BDD scenario `"Invalid argument name with hyphen raises error"` passes without modification to the feature file - [ ] 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 04:13:04 +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
Author
Owner

PR #3243 created on branch fix/action-argument-schema/misleading-error-message. PR review and merge handled by continuous review stream.

Implementation summary:

  • Fixed ActionArgumentSchema.validate_name in src/cleveragents/action/schema.py
  • Changed validation from v.replace("-", "_").isidentifier() to v.isidentifier() — hyphens are now correctly rejected
  • Updated error message from "Use alphanumeric characters, underscores, or hyphens" to "Argument name must be a valid Python identifier" — matching BDD spec exactly
  • Both BDD scenarios ("1invalid" and "invalid-name") now produce the correct error message
  • Lint and typecheck quality gates pass

Automated by CleverAgents Bot
Supervisor: Implementation | Agent: ca-issue-worker

PR #3243 created on branch `fix/action-argument-schema/misleading-error-message`. PR review and merge handled by continuous review stream. **Implementation summary:** - Fixed `ActionArgumentSchema.validate_name` in `src/cleveragents/action/schema.py` - Changed validation from `v.replace("-", "_").isidentifier()` to `v.isidentifier()` — hyphens are now correctly rejected - Updated error message from `"Use alphanumeric characters, underscores, or hyphens"` to `"Argument name must be a valid Python identifier"` — matching BDD spec exactly - Both BDD scenarios (`"1invalid"` and `"invalid-name"`) now produce the correct error message - Lint and typecheck quality gates pass --- **Automated by CleverAgents Bot** Supervisor: Implementation | Agent: ca-issue-worker
Author
Owner

PR #3243 has been merged successfully! 🎉

Summary:

  • Fixed ActionArgumentSchema.validate_name to use v.isidentifier() instead of v.replace("-", "_").isidentifier() — hyphens are now correctly rejected
  • Updated error message to "Argument name must be a valid Python identifier (alphanumeric and underscores, not starting with a digit)" — matching the BDD specification exactly
  • Assigned milestone v3.7.0 to match the linked issue (process requirement per CONTRIBUTING.md)

Review cycles: 1 (one REQUEST CHANGES review requiring milestone assignment, resolved immediately)


Automated by CleverAgents Bot
Supervisor: Implementation | Agent: ca-issue-worker

PR #3243 has been merged successfully! 🎉 **Summary:** - Fixed `ActionArgumentSchema.validate_name` to use `v.isidentifier()` instead of `v.replace("-", "_").isidentifier()` — hyphens are now correctly rejected - Updated error message to `"Argument name must be a valid Python identifier (alphanumeric and underscores, not starting with a digit)"` — matching the BDD specification exactly - Assigned milestone v3.7.0 to match the linked issue (process requirement per CONTRIBUTING.md) **Review cycles:** 1 (one REQUEST CHANGES review requiring milestone assignment, resolved immediately) --- **Automated by CleverAgents Bot** Supervisor: Implementation | Agent: ca-issue-worker
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#3039
No description provided.