Skip to content

Conversation

dcabib
Copy link
Contributor

@dcabib dcabib commented Aug 29, 2025

Description

This PR adds IPv6 support for sourceIp fields in API Gateway, API Gateway v2, and AppSync parser schemas.

Changes

  • Modified packages/parser/src/schemas/api-gateway.ts to accept both IPv4 and IPv6 addresses for sourceIp field
  • Modified packages/parser/src/schemas/api-gatewayv2.ts to accept both IPv4 and IPv6 addresses for http.sourceIp field
  • Modified packages/parser/src/schemas/appsync-shared.ts to accept arrays of both IPv4 and IPv6 addresses for sourceIp field
  • Added comprehensive test cases for IPv6 support in all affected schemas

Testing

  • Added IPv6 test cases to packages/parser/tests/unit/schema/apigw.test.ts
  • Added IPv6 test cases to packages/parser/tests/unit/schema/apigwv2.test.ts
  • Added IPv6 test cases to `packages/parser/tests/unit/schema/appsync.test.ts
  • All tests pass (2358 tests) with 100% code coverage

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

Closes #4348

- Updated api-gateway.ts to support both IPv4 and IPv6 addresses
- Updated api-gatewayv2.ts to support both IPv4 and IPv6 addresses
- Updated appsync-shared.ts to support both IPv4 and IPv6 addresses
- Added comprehensive tests for IPv6 support in all affected schemas

Closes aws-powertools#4348
Copy link

boring-cyborg bot commented Aug 29, 2025

Thanks a lot for your first contribution! Please check out our contributing guidelines and don't hesitate to ask whatever you need.
In the meantime, check out the #typescript channel on our Powertools for AWS Lambda Discord: Invite link

@boring-cyborg boring-cyborg bot added parser This item relates to the Parser Utility tests PRs that add or change tests labels Aug 29, 2025
@pull-request-size pull-request-size bot added the size/L PRs between 100-499 LOC label Aug 29, 2025
- Reverted IPv6 support in appsync-shared.ts (AppSync doesn't support IPv6 yet)
- Removed IPv6 test cases from appsync.test.ts
- Kept IPv6 support for API Gateway and API Gateway v2 only

As mentioned in issue aws-powertools#4348, AppSync does not currently support IPv6
@sdangol
Copy link
Contributor

sdangol commented Aug 29, 2025

I've also marked the SonarQube findings as safe since the ip is hardcoded just for the tests.

@pull-request-size pull-request-size bot added size/M PR between 30-99 LOC and removed size/L PRs between 100-499 LOC labels Aug 29, 2025
- Replace 'as any' with proper TypeScript types in test files
- Use APIGatewayProxyEvent type for API Gateway tests
- Use APIGatewayProxyEventV2 type for API Gateway v2 tests
- Import types from '../../../src/types/schema.js'

This addresses code review feedback for better type safety
Copy link

@dcabib dcabib requested a review from sdangol August 29, 2025 14:05
Copy link
Contributor

@sdangol sdangol left a comment

Choose a reason for hiding this comment

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

Looks good. Thanks @dcabib for your contribution

@sdangol sdangol merged commit 2a94c37 into aws-powertools:main Aug 29, 2025
34 checks passed
Copy link

boring-cyborg bot commented Aug 29, 2025

Awesome work, congrats on your first merged pull request and thank you for helping improve everyone's experience!

@dcabib dcabib deleted the feat/add-ipv6-support-parser branch August 29, 2025 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
parser This item relates to the Parser Utility size/M PR between 30-99 LOC tests PRs that add or change tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: parse sourceIp as ipv6 in APIGateway schemas
3 participants