Conversation
…th x-ms-long-running-operation-options Co-authored-by: raosuhas <11067581+raosuhas@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Update PostResponseCodes rule for new requirements
Update PostResponseCodes: enforce 202+default-only for LRO POST with mandatory x-ms-long-running-operation-options
Mar 6, 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.
LRO POST operations previously allowed
200or204as direct response codes alongside202. The new requirement mandates only202+defaulton the operation itself, with final-state conveyed exclusively viax-ms-long-running-operation-options.final-state-via.Rule changes (
post-response-codes.ts)["202","200","default"]/["202","204","default"]to["202","default"]onlyx-ms-long-running-operation-optionsmust be present withfinal-state-viaset to"location"or"azure-async-operation"LR_NO_SCHEMA_ERROR_OKcheck (200-without-schema) — 200 is no longer a valid LRO response codeLR_SCHEMA_ERROR_NO_CONTENT(204-with-schema) into the sync branch only; 204 on async is already caught by the response-code checkEmptyResponse_ERRORto reflect new requirementsValid LRO POST pattern:
Test changes (
post-response-codes.test.ts)202+200+default,202+204+default) now expect errors; five error-case tests updated for new error counts/messages (addingLR_MISSING_OPTIONS_ERRORwhere applicable)LR_NO_SCHEMA_ERROR_OKreferences withLR_ERROR+LR_MISSING_OPTIONS_ERRORlocation/azure-async-operationoptions, missing options, options with nofinal-state-via, and 200/204 present in LRO responsesOriginal prompt
Summary
The
PostResponseCodesrule and its tests need to be updated to reflect new requirements for POST operation response codes.New Requirements
Sync POST (no
x-ms-long-running-operation: true)200+default(when body present) or204+default(when no body). No other codes allowed.Async POST (
x-ms-long-running-operation: true)202+default. The200and204final-state responses must NOT be present as explicit response codes on the operation itself.x-ms-long-running-operation-optionsextension with"final-state-via"property (values:"location"or"azure-async-operation"). This extension is mandatory for all LRO POST operations.x-ms-long-running-operation-optionsmust be present (withfinal-state-viaset to"location"or"azure-async-operation")x-ms-long-running-operation-optionsmust still be presentIn short:
x-ms-long-running-operation-optionswithfinal-state-viais mandatory for all LRO POST operations.Files to Modify
1.
packages/rulesets/src/spectral/functions/post-response-codes.tsCurrent file (full content for reference):