Skip to content

fix: reconcile gateway APIs and skip missing association targets - #268

Merged
Alexander Zaslonov (azaslonov) merged 4 commits into
Azure:mainfrom
azaslonov:fix/gateway-association-skip-missing-v2
Sep 4, 2026
Merged

fix: reconcile gateway APIs and skip missing association targets#268
Alexander Zaslonov (azaslonov) merged 4 commits into
Azure:mainfrom
azaslonov:fix/gateway-association-skip-missing-v2

Conversation

@azaslonov

Copy link
Copy Markdown
Member

Summary

  • skip missing API/group association targets with a warning so remaining valid gateway and product links continue to publish
  • extract and publish API assignments for the built-in managed gateway without attempting to PUT the managed gateway resource itself
  • reconcile stale gateway API assignments during --delete-unmatched from each tracked gateway's apis.json, leaving untracked gateways untouched

Validation

Related issues

Closes #264
Closes #266

Replaces #267, whose branch included unrelated inherited history. #267 can now be closed.

The built-in 'managed' gateway is not returned by GET /gateways, so its per-API assignments were never extracted, published, or reconciled. This left dev/prod divergence (e.g. an API removed from managed in dev remained assigned in prod).

- extract: query gateways/managed/apis and write gateways/managed/apis.json (only when non-empty)
- publish: skip PUT of the built-in managed Gateway resource (its GatewayApi associations still publish)
- delete-unmatched: reconcile GatewayApi assignments (incl. managed), scoped to gateways that own a local assignment, so untracked gateways are never touched
- add MANAGED_GATEWAY_NAME constant; tests for extract/publish/delete-unmatched
computeGatewayApiDeleteActions compared deployed [gateway,api] descriptors against localSet, which only holds aggregate GatewayApi [gateway] keys (api names live in apis.json content, not the path). Every deployed assignment therefore missed the set and was deleted regardless of desired state - e.g. an API present in the gateway's apis.json was both PUT and DELETEd.

Read the desired API set per gateway via store.readAssociation and delete only deployed assignments absent from it. Update tests to use aggregate local descriptors + readAssociation.
Copilot AI balanced review requested due to automatic review settings September 4, 2026 21:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Empty managed-gateway state, filtering, and environment-mapped gateways are not reconciled correctly.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds managed-gateway assignment support and resilient association publishing, including stale-link reconciliation.

Changes:

  • Extracts and publishes managed gateway API assignments.
  • Skips missing API/group targets without aborting remaining links.
  • Reconciles stale tracked gateway assignments during --delete-unmatched.
File summaries
File Description
src/models/resource-types.ts Defines the managed gateway identifier.
src/services/extract-service.ts Extracts managed gateway API assignments.
src/services/resource-publisher.ts Skips managed gateway PUTs and missing targets.
src/services/delete-unmatched-service.ts Reconciles stale gateway assignments.
tests/unit/services/extract-service.test.ts Tests managed assignment extraction.
tests/unit/services/resource-publisher.test.ts Tests managed skipping and missing targets.
tests/unit/services/delete-unmatched-service.test.ts Tests gateway assignment reconciliation.
Review details
  • Files reviewed: 7/7 changed files
  • Comments generated: 4
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/models/resource-types.ts
Comment thread src/services/delete-unmatched-service.ts Outdated
Comment thread src/services/extract-service.ts Outdated
Comment thread src/services/extract-service.ts
Copilot AI review requested due to automatic review settings September 4, 2026 22:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The implementation addresses the linked issues with focused coverage, and the previously identified mapping, filtering, and empty-state problems are resolved.

Review details
  • Files reviewed: 10/10 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@azaslonov
Alexander Zaslonov (azaslonov) merged commit b694e4e into Azure:main Sep 4, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

4 participants