Skip to content

Add no-route-parameter-name-mismatch linting rule to detect inconsistent path parameter names#4144

Open
Copilot wants to merge 17 commits intomainfrom
copilot/add-linting-rule-for-path-parameters
Open

Add no-route-parameter-name-mismatch linting rule to detect inconsistent path parameter names#4144
Copilot wants to merge 17 commits intomainfrom
copilot/add-linting-rule-for-path-parameters

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 28, 2026

  • Merge latest from main
  • Fix "emit warnings for multiple mismatched parameters" test to use exact routes from reviewer's suggestion: foos/{fooName}/bars/{name} vs foos/{name}/bars/{barName} producing two diagnostics
  • All 54 azure-core test files pass (321 tests), files formatted
  • Include operation names in diagnostic messages
  • Break comparison when allowReserved differs
  • Skip paths with no static segments or consecutive path variables

💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.

Detects when two operation routes differ only by path parameter name.
Skips operations with allowReserved path parameters.
Adds rule to both data-plane and resource-manager rulesets.

Agent-Logs-Url: https://github.com/Azure/typespec-azure/sessions/e2d6639c-a39b-4eaf-a501-9e4def91a83f

Co-authored-by: markcowl <1054056+markcowl@users.noreply.github.com>
@microsoft-github-policy-service microsoft-github-policy-service bot added lib:azure-core Issues for @azure-tools/typespec-azure-core library meta:website TypeSpec.io updates labels Mar 28, 2026
Copilot AI changed the title [WIP] Add linting rule to detect operation paths by parameter name Add no-route-parameter-name-mismatch linting rule to detect inconsistent path parameter names Mar 28, 2026
Copilot AI requested a review from markcowl March 28, 2026 00:53
Copy link
Copy Markdown
Member

@markcowl markcowl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Pull the latest from the main branch and make the suggested changes. Ensure that all tests pass and all fiels are proerly formatted.

Copilot AI and others added 2 commits March 31, 2026 18:34
…ule-for-path-parameters

Co-authored-by: markcowl <1054056+markcowl@users.noreply.github.com>
…skipping

Instead of skipping operations with allowReserved path parameters, the rule
now checks them for both name consistency and allowReserved consistency. A
separate diagnostic (allowReservedMismatch) is emitted when matching path
parameters differ in their allowReserved setting.

Agent-Logs-Url: https://github.com/Azure/typespec-azure/sessions/47627bee-1bca-4437-86b5-29010733205d

Co-authored-by: markcowl <1054056+markcowl@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 31, 2026

@copilot Pull the latest from the main branch and make the suggested changes. Ensure that all tests pass and all fiels are proerly formatted.

Merged latest from main and applied the suggested changes for allowReserved handling in 0a8e964. All 54 test files pass (318+ tests), formatting and spelling verified.

Copilot AI requested a review from markcowl March 31, 2026 18:48
@markcowl markcowl added the int:azure-specs Run integration tests against azure-rest-api-specs label Mar 31, 2026
@markcowl
Copy link
Copy Markdown
Member

@copilot Please pull the latest from main and regenerate samples - fix any issues that cause unexpected diagnostics in existing specs.

@markcowl
Copy link
Copy Markdown
Member

@copilot also validate that all tests are passing and all files are correctly formatted.

@markcowl
Copy link
Copy Markdown
Member

@copilot Also, contrary to my previous suggestion, we should not attempt to match parameters that have differing 'allowReserved' settings. Please adjust the tests and the code as appropriate, pull the latest from main, ensure all tests are passing and all files are correctly formatted

…ples

Extension resources legitimately use different allowReserved scope
parameter names ({resourceUri} vs {scope}). When both parameters at
the same position use allowReserved, skip the name mismatch check.
Regenerated docs to include the new rule in linter reference.

Agent-Logs-Url: https://github.com/Azure/typespec-azure/sessions/526d3364-b839-4f9a-b5e7-8ae4e6676796

Co-authored-by: markcowl <1054056+markcowl@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 31, 2026

@copilot Please pull the latest from main and regenerate samples - fix any issues that cause unexpected diagnostics in existing specs.

Pulled latest from main, regenerated samples/docs, and fixed the unexpected diagnostic in operations/operation-provider in 7f3903b. The issue was that extension resources using ExtensionResourceActionScope ({resourceUri}) and ExtensionActionScope ({scope}) both use allowReserved: true but with different names — this is a legitimate ARM pattern. Updated the rule to skip name mismatch checks when both parameters at the same position use allowReserved. All 54 azure-core test files and 68 sample tests pass.

…param uses allowReserved

Agent-Logs-Url: https://github.com/Azure/typespec-azure/sessions/eed61191-36ca-4ed5-9185-aa5020b30f76

Co-authored-by: markcowl <1054056+markcowl@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 31, 2026

@copilot Also, contrary to my previous suggestion, we should not attempt to match parameters that have differing 'allowReserved' settings. Please adjust the tests and the code as appropriate, pull t...

Removed the allowReservedMismatch diagnostic entirely and updated the rule to skip name comparison when either parameter at a position uses allowReserved (39f7331). This fixes the false positive on the operations/operation-provider sample where {resourceUri} and {scope} are both allowReserved scope parameters. Updated tests (9 cases), docs, and verified all 54 azure-core test files (319 tests) and 68 sample tests pass. Files are formatted.

@copilot also validate that all tests are passing and all files are correctly formatted.

Validated in 39f7331 — all 54 azure-core test files pass (319 tests), all 68 sample tests pass, and files are correctly formatted.

Copilot AI and others added 2 commits April 2, 2026 21:40
…ule-for-path-parameters

Co-authored-by: markcowl <1054056+markcowl@users.noreply.github.com>
…-mismatch rule

Agent-Logs-Url: https://github.com/Azure/typespec-azure/sessions/deb5142d-513b-4111-8442-e814a1b12f78

Co-authored-by: markcowl <1054056+markcowl@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 2, 2026

Pull the latest, make the requested changes. Add new tests to validate the change. veirfy that all tests are passing and all files are properly formatted.

Fixed in a2d52ea. Pulled latest from main, updated the rule to skip paths with consecutive path variables (no static segment between them), and added a test. All 54 azure-core test files pass (321 tests), all 68 sample tests pass, files are formatted.

Copilot AI requested a review from markcowl April 2, 2026 21:55
@markcowl
Copy link
Copy Markdown
Member

markcowl commented Apr 3, 2026

/azp run typespec-azure - PR Tools

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@azure-sdk
Copy link
Copy Markdown
Collaborator

azure-sdk commented Apr 3, 2026

All changed packages have been documented.

  • @azure-tools/typespec-azure-core
  • @azure-tools/typespec-azure-rulesets
Show changes

@azure-tools/typespec-azure-core - feature ✏️

Add no-route-parameter-name-mismatch linting rule that detects when two operation routes differ only by path parameter name.

@azure-tools/typespec-azure-rulesets - feature ✏️

Add no-route-parameter-name-mismatch linting rule that detects when two operation routes differ only by path parameter name.

@azure-sdk
Copy link
Copy Markdown
Collaborator

azure-sdk commented Apr 3, 2026

You can try these changes here

🛝 Playground 🌐 Website

Copy link
Copy Markdown
Member

@markcowl markcowl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull the latest from main, make the changes suggested, make test validation changes to match, and add test coverage if necessary to cover code changes in the linting rule.

Ensure all tests pass, all files are formatted correctly, and the branch is up to date with main, with no merge issues

Copilot AI and others added 2 commits April 3, 2026 19:21
…ule-for-path-parameters

Co-authored-by: markcowl <1054056+markcowl@users.noreply.github.com>
…h, update tests

Agent-Logs-Url: https://github.com/Azure/typespec-azure/sessions/e217ec23-11fb-4e1c-bd0c-86ffee2e5fbd

Co-authored-by: markcowl <1054056+markcowl@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 3, 2026

Pull the latest from main, make the changes suggested, make test validation changes to match, and add test coverage if necessary to cover code changes in the linting rule.

Ensure all tests pass, all ...

Pulled latest from main and applied all requested changes in 1f204ec. All 54 azure-core test files pass (321 tests), all 68 sample tests pass, and files are formatted correctly.

Copilot AI requested a review from markcowl April 3, 2026 19:38
Copy link
Copy Markdown
Member

@markcowl markcowl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make the changes, validate that all tests pass and all files are correctly formatted. Pull the latest from main ensure there are no merge issues and only the files that are part of this change are in the PR

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 3, 2026

Make the changes, validate that all tests pass and all files are correctly formatted. Pull the latest from main ensure there are no merge issues and only the files that are part of this change are in...

Fixed in 47e7f4a. Pulled latest from main (already up to date), updated the test to use exact routes from reviewer's suggestion, all 54 azure-core test files pass (321 tests), files are formatted. Only the test file changed in this commit.

@markcowl markcowl marked this pull request as ready for review April 3, 2026 21:52
Copilot AI requested a review from markcowl April 3, 2026 21:54
@markcowl
Copy link
Copy Markdown
Member

markcowl commented Apr 3, 2026

/azp run typespec-azure - CI

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

int:azure-specs Run integration tests against azure-rest-api-specs lib:azure-core Issues for @azure-tools/typespec-azure-core library meta:website TypeSpec.io updates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ARM]: Need a linting rule to detect operation paths that differ only by path parameter name

3 participants