Skip to content

[http-client-python] AttributeError: 'int' object has no attribute 'rstrip' in preprocess update_description #11138

Description

@msyyc

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.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingemitter:client:pythonIssue for the Python client emitter: @typespec/http-client-python

Type

Fields

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions