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:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user