From eb783e873572472b3ef21b37075ade8bf9e57e87 Mon Sep 17 00:00:00 2001 From: Jeffrey Phillips Freeman Date: Sun, 5 Apr 2026 08:18:05 +0000 Subject: [PATCH] fix(action/schema): correct validate_name error message to say "valid Python identifier" and remove "or hyphens" claim Update ActionArgumentSchema.validate_name to: - Use v.isidentifier() instead of v.replace('-', '_').isidentifier() so hyphens are correctly rejected as invalid argument names - Replace the misleading error message 'Use alphanumeric characters, underscores, or hyphens' with 'Argument name must be a valid Python identifier' to match the BDD spec expectation exactly - Remove the phrase 'or hyphens' which incorrectly implied hyphens were valid argument names ISSUES CLOSED: #3039 --- src/cleveragents/action/schema.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/cleveragents/action/schema.py b/src/cleveragents/action/schema.py index 8ce054207..0d5070cd0 100644 --- a/src/cleveragents/action/schema.py +++ b/src/cleveragents/action/schema.py @@ -122,11 +122,12 @@ class ActionArgumentSchema(BaseModel): @field_validator("name") @classmethod def validate_name(cls, v: str) -> str: - """Ensure argument name is a valid identifier.""" - if not v.replace("-", "_").isidentifier(): + """Ensure argument name is a valid Python identifier.""" + if not v.isidentifier(): raise ValueError( - f"Argument name '{v}' is not a valid identifier. " - "Use alphanumeric characters, underscores, or hyphens." + f"Argument name '{v}' is not a valid Python identifier. " + "Argument name must be a valid Python identifier " + "(alphanumeric and underscores, not starting with a digit)." ) return v