You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Three cases from #4992 cannot be added yet and are commented out in tspcompile.js with an inline reason. All three require fixes in the @azure-tools/typespec-go emitter itself and cannot be worked around by writing tests.
Case
Spec
Stage
Root cause
Head
payload/head
Generation fails
unexpected kind string for HeaderMapResponse metadata
ResponseAsBool
azure/client-generator-core/response-as-bool
Generation fails
didn't find HTTP response for kind boolean (@responseAsBool on HEAD)
Boolean
encode/boolean
Generates OK / fails at runtime
@encode(string) on boolean is ignored; bool is serialized as a JSON boolean instead of a string
1. Head (payload/head) — emitter internal error during preprocessing
../../core/packages/compiler/lib/intrinsics.tsp - error @azure-tools/typespec-go/InternalError:
The emitter encountered an internal error during preprocessing.
Error: unexpected kind string for HeaderMapResponse metadata
at ClientAdapter.adaptResponseEnvelope (src/tcgcadapter/clients.ts:1742:21)
at ClientAdapter.populateMethod (src/tcgcadapter/clients.ts:850:27)
at ClientAdapter.adaptMethod (src/tcgcadapter/clients.ts:688:31)
at ClientAdapter.recursiveAdaptClient (src/tcgcadapter/clients.ts:394:12)
at ClientAdapter.adaptClients (src/tcgcadapter/clients.ts:62:14)
at Adapter.tcgcToGoCodeModel (src/tcgcadapter/adapter.ts:116:8)
A HEAD operation that returns response headers makes the emitter hit an unexpected string kind while processing HeaderMapResponse metadata. No code is generated.
2. ResponseAsBool (azure/client-generator-core/response-as-bool) — emitter internal error during preprocessing
../../core/packages/compiler/lib/intrinsics.tsp:217:8 - error @azure-tools/typespec-go/InternalError:
The emitter encountered an internal error during preprocessing.
Error: didn't find HTTP response for kind boolean in method Exists
at ClientAdapter.adaptResponseEnvelope (src/tcgcadapter/clients.ts:1858:13)
at ClientAdapter.populateMethod (src/tcgcadapter/clients.ts:850:27)
at ClientAdapter.adaptMethod (src/tcgcadapter/clients.ts:688:31)
at ClientAdapter.recursiveAdaptClient (src/tcgcadapter/clients.ts:394:12)
at ClientAdapter.recursiveAdaptClient (src/tcgcadapter/clients.ts:384:32)
at ClientAdapter.adaptClients (src/tcgcadapter/clients.ts:62:14)
at Adapter.tcgcToGoCodeModel (src/tcgcadapter/adapter.ts:116:8)
> 217 | scalar boolean;
| ^^^^^^^
Found 1 error.
For the Exists method (@responseAsBool on HEAD), the emitter cannot find an HTTP response for the boolean kind. No code is generated.
3. Boolean (encode/boolean) — generation succeeds, rejected at runtime
Unlike the other two, generation succeeds (Compilation completed successfully); the failure happens when go test runs against the spector mock:
POST http://localhost:3000/encode/boolean/property/true-lower
RESPONSE 400: 400 Bad Request
{
"message": "Body provided doesn't match expected body: at $.value: expected a string but got boolean",
"expected": { "value": "true" },
"actual": { "value": true }
}
The spec uses @encode(string) so the bool must be serialized as the string "true", but the emitter ignores the annotation and emits the JSON boolean true, which the mock rejects.
Summary
The first two are emitter preprocessing internal errors (no code produced at all); the third is a serialization bug (code is generated but the emitted body does not match the spec). All three are tracked as skipped in tspcompile.js until the emitter is fixed.
exactnamegroup: ["azure/client-generator-core/exact-name", "generate-fakes=false"], // fakes reference an unexported model (my_model), so fake generation is disabled for this scenario
The reason will be displayed to describe this comment to others. Learn more.
It's should be an emitter issue, please also comment out this line
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
emitter:goIssues for @azure-tools/typespec-go emitter
2 participants
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.
add go spector test cases from #4992