Repository navigation
fix: skip WebSocket onHandshake operation on publish - #318
Merged
Alexander Zaslonov (azaslonov) merged 3 commits intoOct 10, 2026
Merged
Alexander Zaslonov (azaslonov) merged 3 commits into
Alexander Zaslonov (azaslonov) merged 3 commits into
Conversation
APIM auto-creates a single system-managed `onHandshake` operation with an
empty urlTemplate for `type: websocket` APIs. PUT/PATCH of that operation
with the extracted `urlTemplate: ""` fails with HTTP 400
("'urlTemplate' should not be empty"), and APIM rejects any user-defined
operation for WebSocket APIs. Skip ApiOperation PUTs when the parent API
artifact declares `type: websocket`; the operation policy is still published.
Fixes Azure#317
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Parent artifact read failures are incorrectly suppressed, potentially masking invalid artifacts and triggering the original APIM error.
1 open finding
What changed in this PR
Prevents publishing APIM-managed WebSocket operations while preserving operation-policy publishing.
Changes:
- Detects WebSocket parent APIs and skips operation PUTs.
- Adds coverage for WebSocket, non-WebSocket, and missing-parent cases.
| File | Description |
|---|---|
src/services/resource-publisher.ts |
Adds WebSocket operation detection and skipping. |
tests/unit/services/resource-publisher.test.ts |
Tests the new publishing behavior. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…operations Let readResource errors propagate to publishResource's failure handling instead of treating them as a missing parent, which would fall through to a PUT that APIM rejects. A missing parent (undefined) still allows the operation PUT. Addresses review feedback on Azure#318.
Move the WebSocket operation check into evaluateResourceEligibility and apply it in planDryRunPublications for both the API-child and direct descriptor paths, so `--dry-run` reports SKIP for `onHandshake` exactly as a real publish does. Addresses review feedback on Azure#318.
Alexander Zaslonov (azaslonov)
approved these changes
Oct 10, 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.

Summary
apiops publishfails with HTTP 400 for WebSocket APIs:PUT apioperation/<api>/onHandshake: 'urlTemplate' should not be empty.APIM auto-creates a single system-managed
onHandshakeoperation with an emptyurlTemplatewhen atype: websocketAPI is created. The extractor persists itas-is, and the publisher (no spec import for WebSocket) re-PUTs it, which APIM rejects.
publishResourcenow skipsApiOperationdescriptors whose parent API artifact(with overrides applied) has
properties.type === 'websocket', logging the reasonand reporting the resource as
SKIP. Done inpublishResourceso both thepublishApichild path and the direct incremental path are covered.operations/onHandshake/policies/policy) are still published.parent artifact is missing.
Verified APIM behaviour (api-version 2024-05-01)
operations/onHandshakeurlTemplate: ""'urlTemplate' should not be emptyOperation entity cannot be defined by user for web socket api typeoperations/onHandshake/policies/policyValidation
apiops extract→apiops publishto a second APIM instance:
PUT api,SKIP apioperation,PUT apioperationpolicy,exit 0; policy content matches on the target.
npm run lint,tsc --noEmit,tests/unit/services/resource-publisher.test.ts(87 passed)..squad/ceremonies.mdrequested.Related Issue(s)
Fixes #317