Skip to content

Fix paginated API Gateway usage plan cleanup#249

Merged
GrahamCampbell merged 1 commit intomainfrom
backport-d-paginated-usage-plan-cleanup
May 3, 2026
Merged

Fix paginated API Gateway usage plan cleanup#249
GrahamCampbell merged 1 commit intomainfrom
backport-d-paginated-usage-plan-cleanup

Conversation

@GrahamCampbell
Copy link
Copy Markdown
Contributor

Summary

  • Fetch all API Gateway usage-plan pages before removing REST API stage associations.
  • Treat omitted usage-plan items and apiStages as empty arrays.
  • Add focused pagination and missing-field coverage.

Tests

  • npx mocha --config "test/mocha/unit.cjs" "test/unit/lib/plugins/aws/package/compile/events/api-gateway/lib/hack/disassociate-usage-plan.test.js"
  • npm run lint
  • npm run prettier-check
  • git diff --check

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes incomplete API Gateway usage-plan disassociation during removal by ensuring all usage plans are processed (not just the first page) and by safely handling missing fields in AWS responses.

Changes:

  • Add getAllUsagePlans() helper to paginate APIGateway.getUsagePlans (using position) and aggregate all items.
  • Treat missing response.items and missing usagePlan.apiStages as empty arrays to avoid runtime errors and unintended updates.
  • Expand unit tests to cover pagination and missing-field scenarios, and update expectations to include { limit: 500 }.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
lib/plugins/aws/package/compile/events/api-gateway/lib/hack/disassociate-usage-plan.js Adds paginated usage-plan retrieval and guards against missing items/apiStages during disassociation.
test/unit/lib/plugins/aws/package/compile/events/api-gateway/lib/hack/disassociate-usage-plan.test.js Updates stubs for { limit: 500 } and adds tests for pagination and missing fields.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@GrahamCampbell GrahamCampbell merged commit 210a154 into main May 3, 2026
8 checks passed
@GrahamCampbell GrahamCampbell deleted the backport-d-paginated-usage-plan-cleanup branch May 3, 2026 15:56
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