feat(lambda): add support to purge in two zones#79
Merged
Conversation
Wiz Scan SummaryDisplaying only findings that violated a policy
To detect these findings earlier in the dev lifecycle, try using Wiz Code VS Code Extension. |
ghost
reviewed
Sep 10, 2025
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for purging cache in multiple Cloudflare zones within a Lambda function, allowing the handler to work with both primary and secondary zones when configured. The implementation includes improved error handling that provides detailed feedback about which zones failed during cache purging operations.
Key changes:
- Enhanced handler to support dual zone purging when both
CLOUDFLARE_ZONE_ID_2andBASE_URL_2environment variables are set - Updated error handling to report specific zone failures instead of generic connection errors
- Expanded test coverage to verify dual zone functionality, partial failures, and single zone configurations
Reviewed Changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/index.ts | Refactored handler to support multiple zones with improved error reporting |
| tests/index.test.ts | Added comprehensive test coverage for dual zone scenarios and updated existing tests |
| events/event.json | Minor update to S3 object key for testing purposes |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
tomski747
approved these changes
Sep 10, 2025
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.
Description
This pull request adds support for purging cache in multiple Cloudflare zones and improves error handling and test coverage for the cache purging logic. The main changes include refactoring the handler to support dual zone purging, updating error reporting to handle partial failures, and expanding the test suite to cover these new scenarios.
Dual zone cache purging:
Refactored the
handlerinsrc/index.tsto support purging cache in two Cloudflare zones if bothCLOUDFLARE_ZONE_ID_2andBASE_URL_2environment variables are set. The handler now iterates over all configured zones and purges cache for each. [1] [2]Updated error handling in
src/index.tsso that if cache purging fails in any zone, the error message specifies which zone(s) failed and why, instead of throwing a generic error.Test coverage improvements:
Added new tests in
tests/index.test.tsto verify dual zone purging, partial failures (where one zone succeeds and another fails), and scenarios where only one zone is configured.Updated environment variable cleanup in test setup to include the new zone variables, ensuring test isolation.
Minor update:
events/event.jsonto reflect a new test case.Must