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

[typespec-azure-core]: function getLroMetadata fails to retrieve finalStateVia in tspfile #2364

Open
4 tasks done
dolauli opened this issue Mar 12, 2025 · 3 comments
Open
4 tasks done
Assignees
Labels
bug Something isn't working cli/psh Issues for Azure CLI/PSH features

Comments

@dolauli
Copy link

dolauli commented Mar 12, 2025

Describe the bug

Below are two cases: one for LRO update and the other for LRO deletion

https://github.com/Azure/azure-rest-api-specs/blob/fa6c6015b1633a701edb629c1a759433aa1fdaf2/specification/scvmm/ScVmm.Management/VmmServer.tsp#L44-L48

https://github.com/Azure/azure-rest-api-specs/blob/fa6c6015b1633a701edb629c1a759433aa1fdaf2/specification/scvmm/ScVmm.Management/VmmServer.tsp#L54-L59

When I attempt to use the following code to retrieve finalStateVia

const lro = getLroMetadata(...);
const finalStateVia = lro.finalStateVia;

Expected value of finalStateVia:

azure-async-operation

Actual value:

location

Reproduction

Added in the description

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.
@dolauli dolauli added bug Something isn't working cli/psh Issues for Azure CLI/PSH features labels Mar 12, 2025
@markcowl markcowl self-assigned this Mar 17, 2025
@markcowl
Copy link
Member

markcowl commented Mar 17, 2025

@dolauli Here is a playground showing how to accomplish this. The idea is that properly-decorated headers need to be specified in the 202 response, and in cases where there are multiple ways to resolve the lro (for example, Azure-AsyncOperation and location header), you can use the @useFinalStateVia decorator to prefer one header over the other in the output.

@markcowl markcowl assigned dolauli and markcowl and unassigned markcowl Mar 17, 2025
@dolauli
Copy link
Author

dolauli commented Mar 19, 2025

Thanks @markcowl for the reply.

The problem I ran into is that there's a bug in the API - getLroMetadata provided in the typespec-azure-core library. Even though azure-async-operation is specified for LRO in the TypeSpec files (as shown in the two examples I provided in the issue description), the API incorrectly returns location for finalStateVia instead of azure-async-operation.

@AllyW
Copy link
Member

AllyW commented Mar 24, 2025

Things also happened in devcenter

tsp api set pollingLocation on Operation-Location but when we fetch its final-state-via through getLroMetadata(program, op).finalStateVia, we will get original-uri instead. Please have a check about this part.

You can reproduce it by checking this playground and x-ms-long-running-operation-options for @azure-tools/typespec-autorest emitter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cli/psh Issues for Azure CLI/PSH features
Projects
None yet
Development

No branches or pull requests

3 participants