Add linting rule to prevent attempts to create long-running GET operations
- Dominant language
- TypeScript
- Stars
- 27
- Forks
- 90
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 156
Description
### Describe the bug
This is [an operation in our recent release for Service Frabric](https://github.com/Azure/azure-rest-api-specs/blob/main/specification/servicefabricmanagedclusters/ServiceFabricManagedClusters.Management/Operations.tsp#L13-L39), the below operation `get` is marked as LRO from the `getLroMetadata` but an non-LRO in Autorest emitter(see [playground](https://cadlplayground.z22.web.core.windows.net/cadl-azure/?c=aW1wb3J0ICJAdHlwZXNwZWMvaHR0cCI7DQrSGnJlc3TWGnZlcnNpb25pbmfNIGF6dXJlLXRvb2xzL8gsLcYVY29yZd8sySxyZXNvdXJjZS1tYW5hZ2VyxDgNCnVzaW5nIEh0dHA7yA1SZXN0yQ1W6QCUyRNBxE8uQ29yZc8TUsdiTcZhxWAvKiogQ29udG9zb8RZxSAgUHJvdmlkZXIg5gCLbWVudCBBUEkuICovDQpAYXJtyCFOYW1lc3BhY2UNCkBzZXJ2aWNlKCN7IHRpdGxlOiAix1nILkh1YkNsaWVudCIgfSkNCkDnAVBlZCjnAMZzKQ0KbshTIE1pY3Jvc29mdC7SSPEAvEFQSSDHUHPlAKdlbnVt6AEecyB7DQogIMQwMjAyMS0xMC0wMS1wcmV2aWV3yDfFNiAgQHVzZURlcGVuZGVuY3ko9QE6LshYLnYxXzBfUMZJXzEpxUFhcm1Db21tb25U5AHhxyvXScspy1U1xUlg8gCsYCwNCn3kAPvEZchMT3BlcmF0xDoNCmludGVyZuQBPkVtcGxveWVl5wD8QHJvdXRlKCIvc3Vic2NyaXDFMS97zA9JZH0vcOcBZHMv6gF%2FU%2BYB2kZhYnJpYy9sb2PGbi97yAt9L%2BYCKWRDbHVzdGVy6QCSUmVzdWx0cy97b8gSSWR9IuYBJ2dldMQIZm9vKMQIICAuLi5BcGnnAQZQYXJhbWV0ZXIsyR1T7QCr0yFM5wCP6AEZzCPGJS8qKsYJICog6QCTIGlkZW50aWZpZXIuyB7lAgsgICNzdXBwcmVzc%2F8D529yZS9uby1vcGVuYXBpIiAiRGF5IDAgcHLEZXR5IsZOQE9wZW7kA0hleHRlbuUCFiJ4LW1zLXDoAKkt6AFSIiwgIm1ldGhvZOYBLiAgQHBhdGjGC%2BsBTTogc3RyaW5n5QEFKTrGIHwgT2tSZXNwb25zZcgSQXJtQWNjZXB0ZWTIGzxFeHRyYUhlYeQB7yA9xCNMcm%2FoAUXGGD7LQE5v5ANtZW50yUEiTm%2FlA4FlbnQuIEZvciBEZWxldGXrAVty5gIBLiLJSUVycm9yyEI75QLP&e=%40azure-tools%2Ftypespec-autorest&options=%7B%7D)). It seems the logic to identify as LRO is inconsistant between Azure core and Autorest emitter. This is un-expected and I think we should align the logic here.
Another thing to mention here this case is migrated from swagger and if we look at [the same operation in previous version](https://github.com/Azure/azure-rest-api-specs/blob/main/specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-09-01-preview/managedcluster.json#L776-L827), it is NOT an LRO. How to guide customers to write correct spec here since it has `Location` header?
```ts
@armResourceOperations
interface Employees {
@route("/subscriptions/{subscriptionId}/providers/Microsoft.ServiceFabric/locations/{location}/managedClusterOperationResults/{operationId}")
@get
get(
...ApiVersionParameter,
...SubscriptionIdParameter,
...LocationResourceParameter,
/**
* operation identifier.
*/
#suppress "@azure-tools/typespec-azure-core/no-openapi" "Day 0 property"
@OpenAPI.extension("x-ms-parameter-location", "method")
@path
operationId: string,
):
| OkResponse
| ArmAcceptedResponse
| ArmNoContentResponse<"No Content. For Delete operation results.">
| ErrorResponse;
}
```
Here is the screenshot from `getLroMetadata` in Azure core lib and the playgrouand for TCGC and autorest emitter returned.
- [TCGC playground](https://cadlplayground.z22.web.core.windows.net/cadl-azure/?c=aW1wb3J0ICJAdHlwZXNwZWMvaHR0cCI7CtIZcmVzdNUZdmVyc2lvbmluZ8wfYXp1cmUtdG9vbHMvyCstxhVjb3Jl3yvIK3Jlc291cmNlLW1hbmFnZXIiOwoKdXNpbmcgSHR0cDvHDFJlc3TIDFbpAI7IEkHESi5Db3JlzhJSx1xNxls7CgovKiogQ29udG9zb8RUxR4gUHJvdmlkZXIg5gCDbWVudCBBUEkuICovCkBhcm3IIE5hbWVzcGFjZQpAc2VydmljZSgjeyB0aXRsZTogIsdXyC1IdWJDbGllbnQiIH0pCkDnAUNlZCjnAL9zKQpuyFAgTWljcm9zb2Z0LtJG7wC2QVBJIMdNc%2BQAoWVudW3oARNzIHsKICDELjIwMjEtMTAtMDEtcHJldmlld8g1xDQgIEB1c2VEZXBlbmRlbmN5KPUBLy7IVi52MV8wX1DGSF8xKcRAYXJtQ29tbW9uVOQBz8cq10jLKctUNcRIYPIAqWAsCn0K5QF4yEhPcGVyYXTENgppbnRlcmbkATNFbXBsb3llZeYA9EByb3V0ZSgiL3N1YnNjcmlwxS8ve8wPSWR9L3DnAVhzL%2BoBc1PmAcxGYWJyaWMvbG9jxmwve8gLfS%2FmAhlkQ2x1c3RlcukAkFJlc3VsdHMve2%2FIEklkfSLlASBnZXQKICBmb28oCiAgICAuLi5BcGnnAP1QYXJhbWV0ZXIsyBxT7QCn0iBM5wCK6AESyyLFIy8qKsUIICog6QCLIGlkZW50aWZpZXIuxx3kAfogICNzdXBwcmVzc%2F8DxG9yZS9uby1vcGVuYXBpIiAiRGF5IDAgcHLEY3R5IsVNQE9wZW7kAy1leHRlbuUCBSJ4LW1zLXDoAKMt6AFHIiwgIm1ldGhvZOUBIyAgQHBhdGjFCusBQDogc3RyaW5n5AD8KTrFHnwgT2tSZXNwb25zZccRQXJtQWNjZXB0ZWTIGjxFeHRyYUhlYeQB3yA9xCNMcm%2FoATrGGD7KP05v5ANSZW50yUAiTm%2FlA2ZlbnQuIEZvciBEZWxldGXrAVJy5gHwLiLISEVycm9yyEE7Cn0K&e=%40azure-tools%2Ftypespec-client-generator-core&options=%7B%22linterRuleSet%22%3A%7B%22extends%22%3A%5B%22%40azure-tools%2Ftypespec-azure-rulesets%2Fresource-manager%22%5D%7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xCNMcm%2FoAUXGGD7LQE5v5ANtZW50yUEiTm%2FlA4FlbnQuIEZvciBEZWxldGXrAVty5gIBLiLJSUVycm9yyEI75QLP&e=%40azure-tools%2Ftypespec-autorest&options=%7B%7D)

### Reproduction
NA
### Checklist
- [x] Follow our [Code of Conduct](https://github.com/azure/typespec-azure/blob/main/CODE_OF_CONDUCT.md)
- [x] 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](https://github.com/Microsoft/TypeSpec/issues/new/choose)
- [x] Check that there isn't already an issue that request the same bug to avoid creating a duplicate.
- [x] The provided reproduction is a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) of the bug.
Contributor guide
Research direction
Start by comparing getLroMetadata in Azure core with the Autorest emitter using the linked TypeSpec playgrounds and the Service Fabric spec versions cited in the issue. Determine the lint condition for GET operations that are incorrectly treated as long-running, including the Location-header case. Done means the rule consistently identifies invalid attempts and provides clear guidance for writing the specification correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100