fix: link cls references when generating commands from TypeSpec - #574
Merged
Ethan Yang (necusjz) merged 1 commit intoSep 22, 2026
Merged
Conversation
Typespec operations are parsed from json, so their cls references arrive without `implement` set, while the swagger builder links them while it builds the schema. `generate_outputs()` runs before `CMDCommand.link()`, so a response body that is a bare cls reference - e.g. the body carrying 202 of the ARM LRO put of Microsoft.Compute galleries - hit an AssertionError in `_build_output_type_schema`.
Ethan Yang (necusjz)
approved these changes
Sep 22, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
AddTypespecreturns 500 (AssertionErrorin_build_output_type_schema) for some resources, e.g. Microsoft.ComputeComputeGallery2026-03-03 galleries / image versions.Root cause
For an ARM LRO
putwhose202carries the resource body, the emitter converts the model twice: the first response owns the definition ("cls": "Gallery_read") and the later one is a bare reference ({"type": "@Gallery_read"}). Swagger links such references while building the schema, but TypeSpec operations are parsed from json and arrive unlinked - andgenerate_outputs()runs beforeCMDCommand.link(), so the output built from the202reference has noimplement.Fix
Link the references in
CMDBuilder.apply_cls_definitions(), which is shared by all three generation entry points and is a no-op for swagger.Testing