Enforce create-only semantics in the TypeScript SDK - #673
Open
Arun G (ArunGopinathan) wants to merge 1 commit into
Open
Enforce create-only semantics in the TypeScript SDK #673Arun G (ArunGopinathan) wants to merge 1 commit into
Arun G (ArunGopinathan) wants to merge 1 commit into
Conversation
Use the standard If-None-Match header for tunnel and port creation, preserve caller-owned request options, and cover generated-ID conflict retries. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1c4ee497-a9b3-481b-860b-541eef9e9fba
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
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.
Why this is needed
The TypeScript SDK sends the nonstandard header
If-Not-Match: *fromcreateTunnelandcreateTunnelPort. The service does not recognize that spelling, so it ignores the intended create-if-absent precondition and falls through to its update path when the tunnel or port already exists.As a result, methods named
create*can silently overwrite existing resources instead of reporting a conflict. This also differs from the C# SDK, which already sends the standardIf-None-Match: *header.Using
If-None-Match: *restores the intended atomic create-only contract:409 ConflictcreateOrUpdateTunnelorcreateOrUpdateTunnelPortThe service's Azure controller already implements this behavior through
Request.Headers.IfNoneMatch, and the C# SDK relies on it in production.What changed
If-Not-Match: *headers withIf-None-Match: *Tests
npm run buildnode .\build.js test --filter TunnelManagementTests(22 passed)npm run eslintSecurity
The server evaluates the create-if-absent precondition atomically, closing the previous overwrite window. Request options and nested headers are copied so the precondition cannot leak into later update calls. Independent correctness reviews and a STRIDE review found no remaining issues.