Skip to content

Enforce create-only semantics in the TypeScript SDK  - #673

Open
Arun G (ArunGopinathan) wants to merge 1 commit into
mainfrom
agopinathan/ts-sdk-if-none-match-typo
Open

Enforce create-only semantics in the TypeScript SDK #673
Arun G (ArunGopinathan) wants to merge 1 commit into
mainfrom
agopinathan/ts-sdk-if-none-match-typo

Conversation

@ArunGopinathan

@ArunGopinathan Arun G (ArunGopinathan) commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Why this is needed

The TypeScript SDK sends the nonstandard header If-Not-Match: * from createTunnel and createTunnelPort. 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 standard If-None-Match: * header.

Using If-None-Match: * restores the intended atomic create-only contract:

  • creating a new tunnel or port succeeds
  • creating one that already exists returns 409 Conflict
  • callers that intentionally want upsert behavior continue to use createOrUpdateTunnel or createOrUpdateTunnelPort

The service's Azure controller already implements this behavior through Request.Headers.IfNoneMatch, and the C# SDK relies on it in production.

What changed

  • replace both If-Not-Match: * headers with If-None-Match: *
  • copy request options before adding the precondition so a later update cannot inherit it
  • verify both create paths emit the correct header and preserve caller-provided headers
  • verify generated tunnel-ID conflicts retry with a new ID while retaining the precondition

Tests

  • npm run build
  • node .\build.js test --filter TunnelManagementTests (22 passed)
  • npm run eslint

Security

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.

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

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@ArunGopinathan Arun G (ArunGopinathan) changed the title Fix TypeScript create precondition headers Enforce create-only semantics in the TypeScript SDK  Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant