Skip to content

[Bug]: TCGC getClientNameOverride returns an object (instead of string or null) #699

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

Closed
4 tasks done
weidongxu-microsoft opened this issue Apr 19, 2024 · 11 comments
Closed
4 tasks done
Assignees
Labels
bug Something isn't working needs-area

Comments

@weidongxu-microsoft
Copy link
Member

weidongxu-microsoft commented Apr 19, 2024

Describe the bug

export declare function getClientNameOverride(context: TCGCContext, entity: Type): string | undefined;

but it returns an object when the issue happens
image

Reproduction

loadtesting
https://github.com/Azure/azure-rest-api-specs-pr/blob/c4b80c74909bf593825e29ce7ff459decba35efd/specification/loadtestservice/LoadTestService/tspconfig.yaml

PR https://github.com/Azure/azure-rest-api-specs-pr/pull/17749

operation is

createOrUpdateTest is StandardResourceOperations.ResourceCreateOrUpdate<Test>;

they also have a

@@clientName(Azure.Core.Foundations.ResourceBody.resource, "body");

in routes.tsp, not sure if related.

call to getClientNameOverride is on the ModelProperty of the Test model.

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.
@mitsha-microsoft
Copy link
Member

Hi @weidongxu-microsoft ,
I am from the load testing team. Is this bug present in the version we install via npm as well, as I am not able to generate C# SDKs for my APIs

@weidongxu-microsoft
Copy link
Member Author

weidongxu-microsoft commented Apr 19, 2024

@mitsha-microsoft

It likely present in the csharp emitter as well. But you may want to contact csharp dev on this, as it may not be the only cause.
(you can try comment out the @@clientName(Azure.Core.Foundations.ResourceBody.resource, "body"); -- TCGC dev and me both think this line is suspicious -- if emitter works without this line in routes.tsp, likely this is the cause)

I'm Java and this is the only problem on Java emitter.

@tadelesh
Copy link
Member

I could not reproduce locally. You mean call getClientNameOverride for the body parameter will return object?

@tadelesh tadelesh self-assigned this Apr 22, 2024
@tadelesh
Copy link
Member

@timotheeguerin in tcgc, the decorator function could not get string value, but a decorator object (minimum tsp case here). i'm wondering if it is a tsp bug?
image

@markcowl markcowl assigned tadelesh and timotheeguerin and unassigned tadelesh Apr 22, 2024
@timotheeguerin
Copy link
Member

timotheeguerin commented Apr 22, 2024

Is this only happening in that specific case? I was trying with the @doc decorator instead and that seems to work fine with the playground you shared.

@tadelesh can try you make a unit test reproing in Tcgc but without using azure core and I'll debug

@tadelesh
Copy link
Member

tadelesh commented Apr 23, 2024

@timotheeguerin i could repro with this tsp.
image

@timotheeguerin
Copy link
Member

ok so the trigger is augmenting a templated type with @clientName but what is weird is it doesn't apply to other decorators

@timotheeguerin
Copy link
Member

hhm actually happens to @extension as well. So seems like maybe the compiler decorators work for some reason but libraries don't

@timotheeguerin
Copy link
Member

Filed this microsoft/typespec#3211 and fix here microsoft/typespec#3212

@timotheeguerin
Copy link
Member

@weidongxu-microsoft @tadelesh can you confirm this has been fixed with latest compiler and so can we close this issue?

@tadelesh
Copy link
Member

@timotheeguerin I've tested in TCGC and it has been fixed. Thank you so much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-area
Projects
None yet
Development

No branches or pull requests

4 participants