Skip to content

Commit d218e73

Browse files
committed
Drop incidental version f-string NameError change; keep only api_version attribute fix
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9e983f91-eed5-4191-b531-0eca9e696313
1 parent 9864c76 commit d218e73

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

.chronus/changes/fix-api-version-validation-attr-2026-7-24-11-30-0.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ packages:
44
- "@typespec/http-client-python"
55
---
66

7-
Fix the generated `_validation.py` `@api_version_validation` decorator so it reads the correct client config attribute for the API version. Previously it hardcoded `client._config.api_version`, but the config attribute name comes from the API-version parameter's `client_name`. For specs that name the versioning parameter something other than `apiVersion` (e.g. Azure Storage's `@apiVersion @header("x-ms-version") version: string`, which produces `self.version`), the hardcoded lookup raised `AttributeError` that the decorator silently swallowed, disabling all API-version validation for those clients. The emitter now threads the real attribute name into the decorator via a `client_api_version_name` kwarg (emitted only when it differs from the default `api_version`). Also fixes a latent `NameError` in the decorator's `unsupported` error-message branch that referenced an out-of-scope `version` variable.
7+
Fix the generated `_validation.py` `@api_version_validation` decorator so it reads the correct client config attribute for the API version. Previously it hardcoded `client._config.api_version`, but the config attribute name comes from the API-version parameter's `client_name`. For specs that name the versioning parameter something other than `apiVersion` (e.g. Azure Storage's `@apiVersion @header("x-ms-version") version: string`, which produces `self.version`), the hardcoded lookup raised `AttributeError` that the decorator silently swallowed, disabling all API-version validation for those clients. The emitter now threads the real attribute name into the decorator via a `client_api_version_name` kwarg (emitted only when it differs from the default `api_version`).

packages/http-client-python/generator/pygen/codegen/templates/validation.py.jinja2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ def api_version_validation(**kwargs):
4949
if unsupported:
5050
raise ValueError("".join([
5151
f"'{param}' is not available in API version {client_api_version}. "
52-
f"Use service API version {param_api_version} or newer.\n"
53-
for param, param_api_version in unsupported.items()
52+
f"Use service API version {version} or newer.\n"
53+
for param, version in unsupported.items()
5454
]))
5555
return func(*args, **kwargs)
5656
return wrapper

0 commit comments

Comments
 (0)