Skip to content

Handle revisioned API deletion in --delete-unmatched and add integration coverage#178

Draft
EMaher with Copilot wants to merge 7 commits into
mainfrom
copilot/delete-unmatched-parameter-fix
Draft

Handle revisioned API deletion in --delete-unmatched and add integration coverage#178
EMaher with Copilot wants to merge 7 commits into
mainfrom
copilot/delete-unmatched-parameter-fix

Conversation

Copilot AI commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

apiops publish --delete-unmatched could fail to remove APIs with revisions because root and revision deletes were executed in an order APIM rejects (Cannot delete the current revision of an API). This left dependent resources undeletable in the same run.

  • Delete orchestration fix (publish path)

    • In publish-service, API deletes are now processed separately from other resources.
    • API delete order is deterministic and revision-aware: revision descriptors are deleted before their root API descriptor, and API deletes run sequentially to avoid race/order conflicts inside the same API family.
    • Non-API resources keep parallel delete behavior.
  • Unit coverage for regression and ordering

    • Added tests proving:
      • orders-api;rev=2 is deleted before orders-api.
      • Ordering remains deterministic across multiple API families (including revision + root pairs).
  • Integration coverage for --delete-unmatched

    • Added a new round-trip phase (Phase 7, run-phase7-delete-unmatched.ps1) that:
      • removes a known revisioned API from extracted artifacts,
      • runs publish with --delete-unmatched,
      • verifies both revision and root API resources are removed from target APIM.
    • Renumbered subsequent round-trip phase labels so teardown is now Phase 8 (run-phase8-teardown.ps1).
    • Wired these updates into both the round-trip orchestrator and integration-test.yml.
    • Updated integration README to document the renumbered phases.
function orderApiDescriptorsForDelete(descriptors: ResourceDescriptor[]): ResourceDescriptor[] {
  return [...descriptors].sort((a, b) => {
    const aName = getNamePart(a.nameParts, 0);
    const bName = getNamePart(b.nameParts, 0);
    const aRoot = getApiRootName(aName);
    const bRoot = getApiRootName(bName);

    if (aRoot !== bRoot) return aRoot.localeCompare(bRoot);

    const aIsRevision = isApiRevisionName(aName);
    const bIsRevision = isApiRevisionName(bName);

    if (aIsRevision === bIsRevision) return aName.localeCompare(bName);
    return aIsRevision ? -1 : 1;
  });
}

Copilot AI changed the title [WIP] Fix deletion of unmatched APIs with revisions Handle revisioned API deletion in --delete-unmatched and add integration coverage Jun 22, 2026
Copilot AI requested a review from EMaher June 22, 2026 05:48
Comment thread .github/workflows/integration-test.yml Outdated
@EMaher EMaher force-pushed the copilot/delete-unmatched-parameter-fix branch from f4e93d9 to 590a88f Compare July 1, 2026 22:53
EMaher added 4 commits July 2, 2026 02:54
- Updated PowerShell scripts in the integration tests to improve readability and maintainability.
- Replaced the use of `Invoke-MaskedApiopsCommand` and `Invoke-MaskedAzCommand` with direct calls to the `apiops` CLI and `az` commands, enhancing error handling and output masking.
- Introduced a new teardown phase script to handle resource group deletions and soft-deletion purging of APIM instances.
- Removed the phase for validating delete-unmatched behavior and integrated its functionality into the publish phase.
- Added support for a `--delete-unmatched` switch in the publish phase to manage unmatched resources during deployment.
- Enhanced secret redaction in logs by implementing a `Protect-Secret` function for better handling of sensitive information.
- Updated documentation and comments for clarity and consistency across scripts.
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