[XmsClientName] Optimize rule to prevent stack overflow on large specs#846
Merged
mikeharder merged 10 commits intomainfrom Mar 31, 2026
Merged
[XmsClientName] Optimize rule to prevent stack overflow on large specs#846mikeharder merged 10 commits intomainfrom
mikeharder merged 10 commits intomainfrom
Conversation
…rge specs Agent-Logs-Url: https://github.com/Azure/azure-openapi-validator/sessions/0305feed-7308-494c-8fe0-c2e25316d9b0 Co-authored-by: mikeharder <9459391+mikeharder@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
mikeharder
March 31, 2026 03:49
View session
mikeharder
reviewed
Mar 31, 2026
mikeharder
reviewed
Mar 31, 2026
packages/rulesets/src/spectral/functions/Extensions/xms-client-name.ts
Outdated
Show resolved
Hide resolved
…ranteed by given clause) Agent-Logs-Url: https://github.com/Azure/azure-openapi-validator/sessions/7881f5ed-00de-4fd7-ba94-e18ff7415de4 Co-authored-by: mikeharder <9459391+mikeharder@users.noreply.github.com>
Member
|
@copilot: fix the formatting of this file: |
…ettier) Agent-Logs-Url: https://github.com/Azure/azure-openapi-validator/sessions/d4e80c49-8c48-45c1-9757-a8baa9053cf5 Co-authored-by: mikeharder <9459391+mikeharder@users.noreply.github.com>
Contributor
Author
mikeharder
reviewed
Mar 31, 2026
9 tasks
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the Spectral XmsClientName rule to avoid JSONPath traversal patterns that can trigger stack overflows on very large OpenAPI specs, while keeping the rule’s behavior the same and aligning generated artifacts/tests with the new approach.
Changes:
- Updated the XmsClientName rule
givenJSONPath to filter earlier (@ != null+x-ms-client-nameexists) to prevent stack overflows on large specs. - Simplified the
xmsClientNamefunction by removing guards now guaranteed by thegivenclause. - Refactored/expanded unit tests for edge cases (missing
x-ms-client-name, null property values) and bumped rulesets version + changelog entry.
Reviewed changes
Copilot reviewed 5 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/rulesets/src/spectral/az-common.ts | Updates XmsClientName.given to a safer early-filtering JSONPath pattern. |
| packages/rulesets/src/spectral/functions/Extensions/xms-client-name.ts | Removes redundant null/object/undefined checks relying on the updated given clause. |
| packages/rulesets/src/spectral/test/xms-client-name.test.ts | Refactors tests with a helper + adds coverage for nodes filtered by the new given clause. |
| packages/rulesets/generated/spectral/az-common.js | Regenerates compiled ruleset with updated given and simplified function. |
| packages/rulesets/generated/spectral/az-arm.js | Regenerates compiled ruleset with updated given and simplified function. |
| packages/rulesets/generated/spectral/az-dataplane.js | Regenerates compiled ruleset with updated given and simplified function. |
| packages/rulesets/package.json | Bumps package version to 2.2.6. |
| packages/rulesets/CHANGELOG.md | Adds 2.2.6 entry describing the XmsClientName optimization. |
…github.com/Azure/azure-openapi-validator into copilot/fix-xms-client-name-stack-overflow
tejaswiMinnu
approved these changes
Mar 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
givenclause inXmsClientNamerule to prevent stack overflow on large specsx-ms-client-name === undefinedcheck from the function (guaranteed by given clause)@ != nulland@['x-ms-client-name'] !== undefined)az-common.js,az-arm.js,az-dataplane.js) with the new given clause and functionxms-client-name.test.tsper prettier