Which area does this affect?
packages/http-specs — test coverage gap for type/enum/extensible.
Description
The Python emitter (@typespec/http-client-python) crashes with AttributeError: ''int'' object has no attribute ''rstrip'' for extensible enums whose member names are date/version-like (e.g. 2020-01-01). See emitter bug: #11138
Root cause: the emitter converts the union member name 2020-01-01 to 2020_01_01 in the intermediate YAML code model. When that YAML is deserialized, 2020_01_01 is parsed as the integer 20200101 (YAML treats underscores as digit separators in numbers). The int then flows into update_description as the default description and crashes.
Minimal reproducing spec (a string extensible enum with date-like member names, e.g. an API version enum):
union ApiVersion {
string;
`2020-01-01`: "2020-01-01";
`2021-01-01`: "2021-01-01";
}
The existing extensible enum spector spec at packages/http-specs/specs/type/enum/extensible/main.tsp only covers DaysOfWeekExtensibleEnum, whose member names are plain words (Monday, ...). There is no coverage for extensible enums whose member names are numeric/date/version-like strings and therefore round-trip through YAML as integers.
Request
Add a spector scenario under type/enum/extensible (or a sibling folder) covering a string extensible enum whose member names look like dates/versions, e.g.:
@doc("Service API versions")
union ApiVersionExtensibleEnum {
string,
@doc("Version 2020-01-01.")
`v2020-01-01`: "2020-01-01",
@doc("Version 2021-01-01.")
`v2021-01-01`: "2021-01-01",
}
with @scenario get/put routes for known and unknown values, mirroring the existing string-based String interface (known value, unknown value, put known, put unknown).
Why
- Exercises extensible enum member names that serialize as integers when round-tripped through YAML.
- Prevents regressions like the Python
update_description crash from going undetected across emitters.
Which area does this affect?
packages/http-specs— test coverage gap fortype/enum/extensible.Description
The Python emitter (
@typespec/http-client-python) crashes withAttributeError: ''int'' object has no attribute ''rstrip''for extensible enums whose member names are date/version-like (e.g.2020-01-01). See emitter bug: #11138Root cause: the emitter converts the union member name
2020-01-01to2020_01_01in the intermediate YAML code model. When that YAML is deserialized,2020_01_01is parsed as the integer20200101(YAML treats underscores as digit separators in numbers). The int then flows intoupdate_descriptionas the default description and crashes.Minimal reproducing spec (a string extensible enum with date-like member names, e.g. an API version enum):
The existing extensible enum spector spec at
packages/http-specs/specs/type/enum/extensible/main.tsponly coversDaysOfWeekExtensibleEnum, whose member names are plain words (Monday, ...). There is no coverage for extensible enums whose member names are numeric/date/version-like strings and therefore round-trip through YAML as integers.Request
Add a spector scenario under
type/enum/extensible(or a sibling folder) covering a string extensible enum whose member names look like dates/versions, e.g.:with
@scenarioget/put routes for known and unknown values, mirroring the existing string-basedStringinterface (known value, unknown value, put known, put unknown).Why
update_descriptioncrash from going undetected across emitters.