Skip to content
New issue

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

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

Already on GitHub? # to your account

[TypeSpec False Positives] EvenSegmentedPathForPutOperation and XmsPageableForListCalls with @singleton #646

Open
mikeharder opened this issue Jan 18, 2024 · 1 comment
Assignees

Comments

@mikeharder
Copy link
Member

mikeharder commented Jan 18, 2024

The regex used by EvenSegmentedPathForPutOperation requires the last path segment to be wrapped in curly braces:

match: ".*/providers/\\w+.\\w+(/\\w+/{\\w+})+$",

This fails to match the OpenAPI generated by TypeSpec @singletons:

@singleton
model Employee is TrackedResource<EmployeeProperties>

.../providers/Microsoft.ContosoProviderHub/employees/default

But it does match the OpenAPI generated by TypeSpec when not using @singleton:

model Employee is TrackedResource<EmployeeProperties> {

.../providers/Microsoft.ContosoProviderHub/employees/{employeeName}

Should EvenSegmentedPathForPutOperation be adjusted to make optional the curly braces around the last path segment? Or even allow only the string default for TypeSpec singletons?

Rule XmsPageableForListCalls has a similar bug but in the opposite direction. It assumes if a path does not end with }, it must specify x-ms-pageable, which I believe should not apply to the default path generated from TypeSpec @singleton.

given: "$[paths,'x-ms-paths'][?(!@property.endsWith('}'))].get",

@mikeharder mikeharder changed the title [TypeSpec False Positive] EvenSegmentedPathForPutOperation fails if last path segment not wrapped in curly braces [TypeSpec False Positives] EvenSegmentedPathForPutOperation and XmsPageableForListCalls with @singleton Jan 18, 2024
@mikeharder mikeharder self-assigned this May 6, 2024
@mikeharder mikeharder moved this from 🤔 Triage to 🐝 Dev in Azure SDK EngSys 🤖🧠 May 7, 2024
@mikeharder mikeharder moved this from 🐝 Dev to 📋 Backlog in Azure SDK EngSys 🤖🧠 May 8, 2024
@mikeharder mikeharder removed their assignment May 9, 2024
@gary-x-li
Copy link

Here's another example. Perhaps consider allowing the word current as singleton as well: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.HybridCompute/networkConfigurations/current

@mikeharder mikeharder assigned tejaswiMinnu and unassigned AkhilaIlla Sep 9, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants