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

Changed ActionArgumentSchema.validate_name in src/cleveragents/action/schema.py:

- Replaced v.replace("-", "_").isidentifier() with v.isidentifier() so hyphens are correctly rejected instead of silently accepted

- Updated error message to say "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"

ISSUES CLOSED: #3039
This commit is contained in:
HAL9000
2026-04-23 09:46:36 +00:00
committed by Forgejo
parent ca050538fb
commit 253f59e8b1
+5 -4
View File
@@ -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