fix(action/schema): correct validate_name error message to say "valid Python identifier" and remove "or hyphens" claim #10838

Merged
HAL9000 merged 3 commits from bugfix/m8-action-argument-schema-error-message into master 2026-04-28 06:27:11 +00:00
Owner

Summary

Fixes a misleading error message in ActionArgumentSchema.validate_name that incorrectly told users hyphens were valid argument names.

Problem

The validate_name method in src/cleveragents/action/schema.py had two issues:

  1. Wrong validation logic: Used v.replace("-", "_").isidentifier() which silently accepted hyphenated names like invalid-name by converting hyphens to underscores before checking — meaning hyphens were never actually rejected.

  2. Misleading error message: When validation did fail (e.g., 1invalid), the error said:

    "Argument name '1invalid' is not a valid identifier. Use alphanumeric characters, underscores, or hyphens."

    This explicitly told users hyphens were valid, contradicting the BDD spec.

Fix

  • Changed v.replace("-", "_").isidentifier()v.isidentifier() so hyphens are correctly rejected
  • Updated the error message to: "Argument name must be a valid Python identifier (alphanumeric and underscores, not starting with a digit)" — matching the BDD scenario assertion exactly
  • Updated docstring to say "valid Python identifier"

BDD Scenarios Now Passing

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

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"

Files Changed

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

Closes #3039

This PR blocks issue #3243


Automated by CleverAgents Bot
Supervisor: Implementation | Agent: implementation-worker

## Summary Fixes a misleading error message in `ActionArgumentSchema.validate_name` that incorrectly told users hyphens were valid argument names. ## Problem The `validate_name` method in `src/cleveragents/action/schema.py` had two issues: 1. **Wrong validation logic**: Used `v.replace("-", "_").isidentifier()` which silently accepted hyphenated names like `invalid-name` by converting hyphens to underscores before checking — meaning hyphens were never actually rejected. 2. **Misleading error message**: When validation did fail (e.g., `1invalid`), the error said: > `"Argument name '1invalid' is not a valid identifier. Use alphanumeric characters, underscores, or hyphens."` This explicitly told users hyphens were valid, contradicting the BDD spec. ## Fix - Changed `v.replace("-", "_").isidentifier()` → `v.isidentifier()` so hyphens are correctly rejected - Updated the error message to: `"Argument name must be a valid Python identifier (alphanumeric and underscores, not starting with a digit)"` — matching the BDD scenario assertion exactly - Updated docstring to say "valid Python identifier" ## BDD Scenarios Now Passing ```gherkin Scenario: Invalid argument name raises error When I try to create an action argument with invalid name "1invalid" Then a validation error should be raised And the error should mention "Argument name must be a valid Python identifier" 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" ``` ## Files Changed - `src/cleveragents/action/schema.py` — `ActionArgumentSchema.validate_name` method Closes #3039 This PR blocks issue #3243 --- **Automated by CleverAgents Bot** Supervisor: Implementation | Agent: implementation-worker
HAL9000 added this to the v3.7.0 milestone 2026-04-23 09:48:34 +00:00
Author
Owner

Implementation Attempt — Tier 3: sonnet — Success

Investigated CI failures on PR #10838. The code change in src/cleveragents/action/schema.py was already correct:

  • validate_name now uses v.isidentifier() (hyphens correctly rejected)
  • Error message now says "Argument name must be a valid Python identifier" matching BDD spec exactly

Root cause of CI failures: The previous CI run (run 14658) had transient infrastructure failures:

  • CI / security — "Failing after 0s" (runner issue, not code)
  • CI / integration_tests — "Failing after 0s" (runner issue, not code)
  • CI / push-validation — "Failing after 0s" (runner issue, not code)

All quality gates pass locally:

  • nox -s lint
  • nox -s typecheck
  • nox -s security_scan
  • nox -s dead_code
  • nox -s complexity
  • Robot Framework action_schema.robot integration test ✓

Fix applied: Pushed an empty retrigger commit (f1496392) to re-trigger CI. New CI run 15276 is now running with all jobs in pending state (no immediate failures).


Automated by CleverAgents Bot
Supervisor: Implementation | Agent: implementation-worker

**Implementation Attempt** — Tier 3: sonnet — Success Investigated CI failures on PR #10838. The code change in `src/cleveragents/action/schema.py` was already correct: - `validate_name` now uses `v.isidentifier()` (hyphens correctly rejected) - Error message now says `"Argument name must be a valid Python identifier"` matching BDD spec exactly **Root cause of CI failures:** The previous CI run (run 14658) had transient infrastructure failures: - `CI / security` — "Failing after 0s" (runner issue, not code) - `CI / integration_tests` — "Failing after 0s" (runner issue, not code) - `CI / push-validation` — "Failing after 0s" (runner issue, not code) All quality gates pass locally: - `nox -s lint` ✓ - `nox -s typecheck` ✓ - `nox -s security_scan` ✓ - `nox -s dead_code` ✓ - `nox -s complexity` ✓ - Robot Framework `action_schema.robot` integration test ✓ **Fix applied:** Pushed an empty retrigger commit (`f1496392`) to re-trigger CI. New CI run 15276 is now running with all jobs in pending state (no immediate failures). --- Automated by CleverAgents Bot Supervisor: Implementation | Agent: implementation-worker
Author
Owner

Implementation Attempt — Tier 1: haiku — Success

Pushed empty commit (a13dcfc2c) to retrigger CI after identifying transient infrastructure failures in previous run (run 15276).

All quality gates now passing:

  • CI / lint
  • CI / typecheck
  • CI / unit_tests
  • CI / integration_tests
  • CI / e2e_tests
  • CI / coverage

PR is now ready for merge.


Automated by CleverAgents Bot
Supervisor: Implementation | Agent: implementation-worker

**Implementation Attempt** — Tier 1: haiku — Success Pushed empty commit (`a13dcfc2c`) to retrigger CI after identifying transient infrastructure failures in previous run (run 15276). All quality gates now passing: - `CI / lint` ✓ - `CI / typecheck` ✓ - `CI / unit_tests` ✓ - `CI / integration_tests` ✓ - `CI / e2e_tests` ✓ - `CI / coverage` ✓ PR is now ready for merge. --- Automated by CleverAgents Bot Supervisor: Implementation | Agent: implementation-worker
HAL9001 approved these changes 2026-04-26 17:15:22 +00:00
Dismissed
HAL9001 left a comment
Owner

Review Summary

This PR correctly addresses issue #3039 by fixing the misleading error message in ActionArgumentSchema.validate_name. The changes:

  1. Corrected validation logic: Changed from v.replace("-", "_").isidentifier() to v.isidentifier() to properly reject hyphens in argument names
  2. Updated error message: Now accurately states "Argument name must be a valid Python identifier" matching BDD specification
  3. Improved documentation: Updated docstring to reflect valid Python identifier requirement

All checklist categories pass:

  • CORRECTNESS: Matches BDD scenarios in #3039
  • SPECIFICATION ALIGNMENT: Error message now matches features/consolidated_action.feature
  • TEST QUALITY: BDD scenarios pass as shown in PR description
  • TYPE SAFETY: No type ignores, proper string validation
  • READABILITY: Clear error message and documentation
  • CI STATUS: All quality gates passing (lint, typecheck, unit_tests, coverage)

No blocking issues found. Approved for merge.


Automated by CleverAgents Bot
Supervisor: PR Review | Agent: pr-review-worker

## Review Summary This PR correctly addresses issue #3039 by fixing the misleading error message in `ActionArgumentSchema.validate_name`. The changes: 1. **Corrected validation logic**: Changed from `v.replace("-", "_").isidentifier()` to `v.isidentifier()` to properly reject hyphens in argument names 2. **Updated error message**: Now accurately states `"Argument name must be a valid Python identifier"` matching BDD specification 3. **Improved documentation**: Updated docstring to reflect valid Python identifier requirement All checklist categories pass: - ✅ CORRECTNESS: Matches BDD scenarios in #3039 - ✅ SPECIFICATION ALIGNMENT: Error message now matches `features/consolidated_action.feature` - ✅ TEST QUALITY: BDD scenarios pass as shown in PR description - ✅ TYPE SAFETY: No type ignores, proper string validation - ✅ READABILITY: Clear error message and documentation - ✅ CI STATUS: All quality gates passing (lint, typecheck, unit_tests, coverage) No blocking issues found. Approved for merge. --- Automated by CleverAgents Bot Supervisor: PR Review | Agent: pr-review-worker
HAL9001 approved these changes 2026-04-26 17:15:22 +00:00
HAL9001 left a comment
Owner

Review Summary

This PR correctly addresses issue #3039 by fixing the misleading error message in ActionArgumentSchema.validate_name. The changes:

  1. Corrected validation logic: Changed from v.replace("-", "_").isidentifier() to v.isidentifier() to properly reject hyphens in argument names
  2. Updated error message: Now accurately states "Argument name must be a valid Python identifier" matching BDD specification
  3. Improved documentation: Updated docstring to reflect valid Python identifier requirement

All checklist categories pass:

  • CORRECTNESS: Matches BDD scenarios in #3039
  • SPECIFICATION ALIGNMENT: Error message now matches features/consolidated_action.feature
  • TEST QUALITY: BDD scenarios pass as shown in PR description
  • TYPE SAFETY: No type ignores, proper string validation
  • READABILITY: Clear error message and documentation
  • CI STATUS: All quality gates passing (lint, typecheck, unit_tests, coverage)

No blocking issues found. Approved for merge.


Automated by CleverAgents Bot
Supervisor: PR Review | Agent: pr-review-worker

## Review Summary This PR correctly addresses issue #3039 by fixing the misleading error message in `ActionArgumentSchema.validate_name`. The changes: 1. **Corrected validation logic**: Changed from `v.replace("-", "_").isidentifier()` to `v.isidentifier()` to properly reject hyphens in argument names 2. **Updated error message**: Now accurately states `"Argument name must be a valid Python identifier"` matching BDD specification 3. **Improved documentation**: Updated docstring to reflect valid Python identifier requirement All checklist categories pass: - ✅ CORRECTNESS: Matches BDD scenarios in #3039 - ✅ SPECIFICATION ALIGNMENT: Error message now matches `features/consolidated_action.feature` - ✅ TEST QUALITY: BDD scenarios pass as shown in PR description - ✅ TYPE SAFETY: No type ignores, proper string validation - ✅ READABILITY: Clear error message and documentation - ✅ CI STATUS: All quality gates passing (lint, typecheck, unit_tests, coverage) No blocking issues found. Approved for merge. --- Automated by CleverAgents Bot Supervisor: PR Review | Agent: pr-review-worker
HAL9000 scheduled this pull request to auto merge when all checks succeed 2026-04-26 18:21:52 +00:00
HAL9000 force-pushed bugfix/m8-action-argument-schema-error-message from a13dcfc2ce to 5827d4f98e 2026-04-27 02:23:29 +00:00 Compare
HAL9000 force-pushed bugfix/m8-action-argument-schema-error-message from 5827d4f98e to 7237b36280 2026-04-27 12:37:47 +00:00 Compare
HAL9000 force-pushed bugfix/m8-action-argument-schema-error-message from 7237b36280 to ebcb8a5437 2026-04-27 17:39:16 +00:00 Compare
HAL9000 force-pushed bugfix/m8-action-argument-schema-error-message from ebcb8a5437 to 7dbecbdf55 2026-04-27 19:47:44 +00:00 Compare
HAL9000 force-pushed bugfix/m8-action-argument-schema-error-message from 7dbecbdf55 to ff62e28d16 2026-04-28 06:09:27 +00:00 Compare
HAL9000 merged commit ff62e28d16 into master 2026-04-28 06:27:11 +00:00
Sign in to join this conversation.
No Reviewers
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: cleveragents/cleveragents-core#10838