Repository navigation
Labels
bugSomething isn't workingSomething isn't workingemitter:client:pythonIssue for the Python client emitter: @typespec/http-client-pythonIssue for the Python client emitter: @typespec/http-client-python
Description
Emitter version
@typespec/http-client-python 0.34.0
Error stack
========================================= error stack start ================================================
Error: Command failed: C:\dev\typespec\packages\http-client-python\venv\Scripts\python.exe C:\dev\typespec\packages\http-client-python/eng/scripts/setup/run_tsp.py --package-version=1.0.0b1 --generate-packaging-files=true --validate-versioning=true --clear-output-folder=false --flavor=azure --package-name=myservice --package-mode=azure-dataplane --keep-setup-py=false --from-typespec=true --models-mode=dpg --output-folder=C:/dev/typespec/packages/http-client-python/alpha/tsp-output/@typespec/http-client-python --tsp-file=C:/Users/YUCHAO~1/AppData/Local/Temp/tsp-codegen/python-yaml-pathbcbded35-4d27-48c3-99af-e63dd41aa35c.yaml
Traceback (most recent call last):
File "C:\dev\typespec\packages\http-client-python/eng/scripts/setup/run_tsp.py", line 39, in <module>
preprocess.PreProcessPlugin(output_folder=args.output_folder, tsp_file=args.tsp_file, **unknown_args).process()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "C:\dev\typespec\packages\http-client-python\generator\pygen\__init__.py", line 303, in process
self.update_yaml(yaml_data)
~~~~~~~~~~~~~~~~^^^^^^^^^^^
File "C:\dev\typespec\packages\http-client-python\generator\pygen\preprocess\__init__.py", line 706, in update_yaml
self.update_types(yaml_data["types"])
~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
File "C:\dev\typespec\packages\http-client-python\generator\pygen\preprocess\__init__.py", line 459, in update_types
type["description"] = update_description(type.get("description", ""), type["name"])
~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\dev\typespec\packages\http-client-python\generator\pygen\preprocess\__init__.py", line 113, in update_description
description.rstrip(" ")
^^^^^^^^^^^^^^^^^^
AttributeError: 'int' object has no attribute 'rstrip'
at genericNodeError (node:internal/errors:985:15)
at wrappedFn (node:internal/errors:539:14)
at checkExecSyncError (node:child_process:925:11)
at execSync (node:child_process:997:15)
at runNodeEmit (file:///C:/dev/typespec/packages/http-client-python/emitter/src/node-runner.ts:112:3)
at onEmitMain (file:///C:/dev/typespec/packages/http-client-python/emitter/src/emitter.ts:258:5)
at Object.$onEmit [as emitFunction] (file:///C:/dev/typespec/packages/http-client-python/emitter/src/emitter.ts:170:5)
at runEmitter (file:///C:/dev/typespec/packages/http-client-python/node_modules/@typespec/compiler/src/core/program.ts:1007:5)
at file:///C:/dev/typespec/packages/http-client-python/node_modules/@typespec/compiler/src/core/program.ts:979:33
at trackAction (file:///C:/dev/typespec/packages/http-client-python/node_modules/@typespec/compiler/src/core/logger/console-sink.ts:188:20)
========================================= error stack end ================================================
Reproduce
import "@typespec/http";
using TypeSpec.Http;
@service(#{ title: "My Service" })
namespace MyService;
union ApiVersion {
string;
`2020-01-01`: "2020-01-01";
`2021-01-01`: "2021-01-01";
}
model Widget {
id: string;
name: string;
apiVersion: ApiVersion;
}
@route("/widgets")
interface Widgets {
@get list(): Widget[];
@get read(@path id: string): Widget;
@post create(@body widget: Widget): Widget;
}
Running tsp compile . --emit @typespec/http-client-python could reproduce up error.
Reacted by github-actions and Copilot
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingemitter:client:pythonIssue for the Python client emitter: @typespec/http-client-pythonIssue for the Python client emitter: @typespec/http-client-python
Activity
github-actions commentedon Jul 2, 2026
🎯 Issue Triage
The Python emitter crashes with
AttributeError: 'int' object has no attribute 'rstrip'whenupdate_descriptionreceives a non-string (integer) description value from the code model. The issue includes a clear root cause analysis and a suggested fix.Category: Bug
Area:
emitter:client:python🔁 Possible duplicate of #11137 — Issue #11137 was filed 6 seconds earlier by the same author with an identical title and body, describing the exact same bug. One of these should be closed.
@docvalue) would help confirm and diagnose the issue.🔍 Analysis
generator/pygen/preprocess/__init__.py,update_description()(line ~113)@typespec/http-client-python0.34.0descriptionis truthy, so it bypasses theif not descriptionguard and hits.rstrip(" "), which doesn't exist onint. There is also a latent bug: the.rstrip()call discards its return value (no assignment), so trailing-space stripping never actually applies even for valid strings.isinstance(description, str)to the guard, and assign therstripresult back.📝 Suggested next steps
update_descriptionto coerce non-string values:if not description or not isinstance(description, str): description = default_descriptionrstrip: change todescription = description.rstrip(" ")[python] Fix enum member names corrupted by YAML 1.1/1.2 boundary (mi…
[python] Fix enum member names corrupted by YAML 1.1/1.2 boundary (#1…
lirenhe commentedon Jul 16, 2026
close it as completed.