Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: TCGC, lroMetadata.finalResponse.resultPath is neither clientName nor serializedName #2072

Open
4 tasks done
weidongxu-microsoft opened this issue Jan 14, 2025 · 3 comments · May be fixed by #2102
Open
4 tasks done
Assignees
Labels
bug Something isn't working lib:tcgc Issues for @azure-tools/typespec-client-generator-core library

Comments

@weidongxu-microsoft
Copy link
Member

Describe the bug

TCGC 0.49.1

lroMetadata.finalResponse.resultPath is neither clientName nor serializedName

Reproduction

https://cadlplayground.z22.web.core.windows.net/cadl-azure/?c=aW1wb3J0ICJAdHlwZXNwZWMvcmVzdCI7CskZYXp1cmUtdG9vbHMvyCUtxhVjb3Jl3ytjLWNsaWVudC1nZW5lcmF0b3LINgp1c2luZyBUeXBlU3BlYy5IdHRwO9AVUmVzdNEVVmVyc2lvbmluZ8gbQcR5LkNvcmXSEi5UcmFpdHPPGeUAlUfoAJTHOwpAc2VydmljZSh7CiAgdGl0bGU6ICJSZXNwb25zZSIsCn0pCkB2xn5lZChBcGnnAItzKQpuYW1lc3BhY2UgVHNwVGVzdOQAvMU4OwoKZW51bSDLLyDEYEB1c2VEZXBlbmRlbmN5KGdsb2JhbC7rALnILi52MV8wX1ByZXZpZXdfMikKICB2MjAyMl8wNl8wMV9wxhk6ICLEFS0wNi0wMS3HFeQAtAoKb3AgQ3VzdG9tTG9uZ1J1buQBO09w5AD7aW9uPAogIFRQYXJhbXMgZXh0ZW5kc%2BwBgGZsZWPEJy5Nb2RlbCzELegA2d8vZGVsCj4gaXMgRm91bmTFbHMu1HfEVUFjY2VwdGVkyVwm5QEkICBAcG9sbGluZ0xvY8U4xhVoZWFkZXIoIslPLcggIuQBHyAgb8gZyBg6IFJlc291cmNlyBI86QDJPjsKICB9Cj7kAgJyxyYoIsgKcyIpCm3kAM7JQuYBv3Zpc2liaWxpdHnELGFkxXppZDogc3Ry5QKcxCVrZXnZLOQCM80uZGVzY3JpcOQAnT%2FKGSAg5ANMyhB9CgovLyBubyDkAKJ1bHQiIHBy5ADvdHnnAKfpARVEZXRhaWznAm5kb2PrATAgSUTlAIT5AKEsICJjcmVhdGXpANd1dWlk5QCnc3RhdHVzOuwDZPUB41N0YXRl5ADAZXJyb3I%2F2TFFxB%2FFWkBscm9S5QDVxA3mBDpOYW1lKCJs6gK6xiHmAL5lbmNvZGVkxiRhcHBsaeYB3C9qc29u5ADEbHJvX%2BcBJ8Qxxgs%2F6gIN5QFPQPoEFS7mAIXlBBHmAbDpBBDGLyLkAr7nBDc68QP85gQz5QF7yBMiKQpAcm91dGUoIuQFbMgUaW50ZXJm5ARAyClPcCB75QEVyC5scm8t6wDMbHJvSW52YWxp5AM1dWx05ANr%2FgPnIOcDVCAgQGJvZHkgcmVxdWVzdOwBDsQdfeQA0yDxAkcKICA%2B5AEv&e=%40azure-tools%2Ftypespec-client-generator-core&options=%7B%7D

input

  @lroResult
  @clientName("longRunningResult")
  @encodedName("application/json", "lro_result")
  result?: Resource;

output

                - apiVersions:
                    - 2022-06-01-preview
                  type: *a4
                  name: longRunningResult
                  isGeneratedName: false
                  optional: true
                  isApiVersionParam: false
                  onClient: false
                  crossLanguageDefinitionId: TspTest.Response.OperationDetails.result
                  decorators: []
                  kind: property
                  discriminator: false
                  serializedName: lro_result
                  isMultipartFileInput: false
                  flatten: false

            result: *a4
            resultPath: result

The resultPath should be the client name of the property longRunningResult.

Checklist

  • Follow our Code of Conduct
  • Check that this issue is about the Azure libraries for typespec. For bug in the typespec language or core libraries file it in the TypeSpec repo
  • Check that there isn't already an issue that request the same bug to avoid creating a duplicate.
  • The provided reproduction is a minimal reproducible example of the bug.
@weidongxu-microsoft
Copy link
Member Author

weidongxu-microsoft commented Jan 14, 2025

For Java emitter, serializedName would be easier to handle, in the case of LRO, as well as in the case of pageable.

sdkMethod.response.resultPath;
sdkMethod.nextLinkPath;

as we usually parsing these via JSON.

Alternatively, TCGC can directly ref to the property (or array of properties, if there is nested in case of pageable).

@tadelesh tadelesh added the lib:tcgc Issues for @azure-tools/typespec-client-generator-core library label Jan 14, 2025
@ArcturusZhang
Copy link
Member

I think the only way we could deal it gracefully is to make an array of SdkModelProperty.
Making everything to be strings and put "what this string means" in document for people to read is not quite a good design.

@weidongxu-microsoft
Copy link
Member Author

weidongxu-microsoft commented Jan 21, 2025

I think the only way we could deal it gracefully is to make an array of SdkModelProperty. Making everything to be strings and put "what this string means" in document for people to read is not quite a good design.

Yeah, I'd agree to this.

Though there could be some design issues, e.g. maybe due to looped reference (though not likely in LRO method).
Also, "paging" method have similar "string" design, of sdkMethod.response.resultPath and sdkMethod.nextLinkPath.
We may design them together (as for "paging", there is known case of nested properties, e.g. links -> nextLink -- and we really don't wish the nextLinkPath be links.nextLink).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working lib:tcgc Issues for @azure-tools/typespec-client-generator-core library
Projects
None yet
3 participants