Skip to content

Add async LRO polling and OpenAPI spec sanitization#112

Open
petehauge wants to merge 4 commits into
mainfrom
fix/async-lro-and-spec-sanitization
Open

Add async LRO polling and OpenAPI spec sanitization#112
petehauge wants to merge 4 commits into
mainfrom
fix/async-lro-and-spec-sanitization

Conversation

@petehauge
Copy link
Copy Markdown
Collaborator

Summary

Two improvements to the APIM publish pipeline:

1. Async Long-Running Operation (LRO) Polling

Large API spec imports (e.g., 500+ paths) exceed the existing 60-second provisioning state timeout. This adds ARM async operation polling:

  • Captures Azure-AsyncOperation, Operation-Location, and Location response headers from 201/202 responses
  • Polls with a 7.5-minute deadline (duration-based, not attempt-based)
  • Honors Retry-After headers from the service
  • Validates async operation URLs against known ARM management hosts before sending bearer tokens
  • Falls back to existing pollProvisioningState() when no async headers are present
  • Applied to both putResource and deleteResource

2. OpenAPI Spec Sanitization

APIM rejects OpenAPI specs where URL path templates reference parameters not declared in the operation's parameters array. This adds automatic sanitization:

  • Detects missing path parameter declarations before import
  • Auto-injects them as required string path parameters
  • Logs a warning for each injected parameter so users are aware
  • Only processes JSON-based specs; passes through non-JSON specs unchanged

Files Changed

  • src/clients/apim-client.ts - LRO polling implementation
  • src/services/api-publisher.ts - Spec sanitization

@petehauge petehauge changed the title feat: add async LRO polling and OpenAPI spec sanitization Add async LRO polling and OpenAPI spec sanitization Jun 5, 2026
@EMaher EMaher self-requested a review June 6, 2026 04:10
Comment thread src/clients/apim-client.ts
Comment thread src/services/api-publisher.ts Outdated
- Implement ARM async long-running operation (LRO) polling in ApimClient
  for large API spec imports that exceed the 60s provisioning state timeout.
  Polls Azure-AsyncOperation/Location headers with a 7.5-minute deadline,
  honors Retry-After, and validates URLs against known ARM hosts.
- Add supportsGet guard to getResource to short-circuit before network call
  for association resources that only support PUT/DELETE.
- Add OpenAPI spec sanitizer that auto-injects missing path parameter
  declarations before APIM import, with warnings logged for each fix.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@petehauge petehauge force-pushed the fix/async-lro-and-spec-sanitization branch from e3611ff to 05627bc Compare June 6, 2026 05:15
Peter Hauge and others added 3 commits June 5, 2026 22:41
…kage-build tests

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The rebase onto main left expectedCallSequence defined but unused —
main's refactored assertion uses expectedTypes with deduplication.
Renamed the variable and removed the duplicate NamedValue entry
that conflicts with the firstSeenInOrder filter.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
/// <reference types="node" />

import { execFile } from 'node:child_process';
import { exec as execCb } from 'node:child_process';
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTE: the fixes in this file are for running the tests on windows... Some of the packaging unit tests were failing without this...

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.

2 participants