fix(action/schema): correct validate_name error message to say "valid Python identifier" and remove "or hyphens" claim
CI / benchmark-publish (pull_request) Has been skipped
CI / build (pull_request) Successful in 23s
CI / lint (pull_request) Successful in 26s
CI / push-validation (pull_request) Successful in 24s
CI / helm (pull_request) Successful in 33s
CI / quality (pull_request) Successful in 36s
CI / typecheck (pull_request) Successful in 56s
CI / security (pull_request) Successful in 1m1s
CI / e2e_tests (pull_request) Successful in 3m35s
CI / integration_tests (pull_request) Successful in 4m1s
CI / unit_tests (pull_request) Successful in 5m19s
CI / docker (pull_request) Successful in 1m23s
CI / coverage (pull_request) Successful in 10m34s
CI / status-check (pull_request) Successful in 1s
CI / benchmark-regression (pull_request) Successful in 58m12s

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
This commit is contained in:
2026-04-05 08:18:05 +00:00
committed by Forgejo
parent 983f05186a
commit eb783e8735
+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