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 generates incorrect cross-language definition IDs #849

Closed
4 tasks done
tjprescott opened this issue May 16, 2024 · 7 comments · Fixed by #936
Closed
4 tasks done

[Bug]: TCGC generates incorrect cross-language definition IDs #849

tjprescott opened this issue May 16, 2024 · 7 comments · Fixed by #936
Assignees
Labels
bug Something isn't working needs-area

Comments

@tjprescott
Copy link
Member

Describe the bug

See: https://apiview.dev/Assemblies/Review/e3195e5ca7954296b4e68393eb084773#ModelClient.generateImages

The cross-language definition ID for this operation should be ModelClient.getChatCompletions. However, TCGC is transforming the TypeSpec through it's client decorators and so forth and generating an ID of Customizations.Client1.create. The method to generate the cross-language definition ID should not apply any such customizations.

The whole point of the cross-language definition ID is to be the same no matter the language. If a client.tsp applies different customizations for different languages then there's no way those IDs will match.

Reproduction

  1. Create a simple TypeSpec.
  2. Apply TCGC customizations.
  3. Generate the mapping file.

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

two problems here:

  1. i wonder how we could identify whether an operation is from customization and find its source operation? if there a way that we could know a definition is from client.tsp file?
  2. idw whether if we will add more customization which could make find source impossible. i want to know what the rule of cross-language definition id?

@iscai-msft
Copy link
Contributor

  1. I'm not sure about that, that's a good point though, @tjprescott any ideas?
  2. We want cross language definition id to be the same for the tsp definition, and for all of the language emitters, so we shouldn't have any client customizations included in it

@tadelesh tadelesh reopened this Jun 4, 2024
@tjprescott
Copy link
Member Author

@iscai-msft is correct, in order for the cross-language ID to be "cross-language" you can't apply language specific customizations. The only source of truth is the TypeSpec, so the cross-langauge ID should always correspond to the TypeSpec ID.

If you can't trace something back to pure TypeSpec then there would be no cross-language ID. So if you had, for example, a decorator that created some kind of helper operation, there's be no cross-language ID for that helper, but it would only exist in Python.

@tadelesh tadelesh reopened this Jun 6, 2024
@mikeharder
Copy link
Member

I have no idea how my fork of branch typespec-azure could have triggered this issue to be closed.

@timotheeguerin, @markcowl: Any ideas?

image

https://github.com/mikeharder/typespec-azure/commit/3af118a4a6a6a0dacfcd8f37847091948d9d3b37

@mikeharder
Copy link
Member

mikeharder commented Jun 6, 2024

I think it happened when I merged upstream to my fork:

image

Which I think means, this may keep getting re-closed when anybody merges their fork. Which means, you can't really re-open an issue if it was closed by a commit to main.

@tadelesh: I recommend you open an new issue and close this one.

@tadelesh
Copy link
Member

tadelesh commented Jun 6, 2024

@mikeharder ok. thanks for reminder.

@tadelesh
Copy link
Member

tadelesh commented Jun 6, 2024

replaced by #961

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

Successfully merging a pull request may close this issue.

4 participants