diff --git a/.chronus/changes/HEAD-2025-11-16-13-29-48.md b/.chronus/changes/HEAD-2025-11-16-13-29-48.md new file mode 100644 index 00000000000..1d38a28a02a --- /dev/null +++ b/.chronus/changes/HEAD-2025-11-16-13-29-48.md @@ -0,0 +1,7 @@ +--- +changeKind: fix +packages: + - "@typespec/http-client-python" +--- + +fix client default value for special headers \ No newline at end of file diff --git a/packages/http-client-python/generator/pygen/codegen/serializers/builder_serializer.py b/packages/http-client-python/generator/pygen/codegen/serializers/builder_serializer.py index ef61ff347cc..d5db45a3294 100644 --- a/packages/http-client-python/generator/pygen/codegen/serializers/builder_serializer.py +++ b/packages/http-client-python/generator/pygen/codegen/serializers/builder_serializer.py @@ -403,7 +403,12 @@ def declare_non_inputtable_headers_queries( builder: RequestBuilderType, ) -> list[str]: def _get_value(param): - declaration = param.get_declaration() if param.constant else None + if param.constant: + declaration = param.get_declaration() + elif param.client_default_value_declaration is not None: + declaration = param.client_default_value_declaration + else: + declaration = None if param.location in [ParameterLocation.HEADER, ParameterLocation.QUERY]: kwarg_dict = "headers" if param.location == ParameterLocation.HEADER else "params" return f"_{kwarg_dict}.pop('{param.wire_name}', {declaration})"