Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom Decodable conformance #76

Closed
wants to merge 3 commits into from

Conversation

twistinside
Copy link

Add custom Decodable conformance. Closes #73

Motivation:

Absent collections would fail to decode, when in reality it is possible to have empty headers, for example. This allows processing to continue in the context of the Lambda runtime where users can handle the collections as dictated by their code.

Modifications:

Custom Decodable conformance has been added to both API Gateway request objects to optionally decode absent collections to empty collections.

Unit testa have been added for the same.

Result:

This will make the swift lambda runtime more accepting of input, allowing processing to proceed in the rare cases where collection fields would be absent in the JSON received by the runtime. This will unlock certain functionality in edge cases such as testing lambda code from API Gateway console with empty headers (the use case that prompted this change).

This change will require users to update their code to remove optional handling for the collections involved, potentially also requiring extra logic to validate that the collections they've received aren't empty.

@twistinside twistinside changed the title Add custom Decodable conformance Add custom Decodable conformance Nov 21, 2024
@twistinside twistinside marked this pull request as ready for review November 21, 2024 04:57
@sebsto sebsto self-requested a review November 26, 2024 13:40
@sebsto sebsto self-assigned this Nov 26, 2024
@sebsto sebsto added semver/none No version bump required. 🔨 semver/patch No public API change. ⚠️ semver/major Breaks existing public API. and removed semver/none No version bump required. 🔨 semver/patch No public API change. labels Nov 26, 2024
@sebsto
Copy link
Contributor

sebsto commented Nov 26, 2024

Thank you @twistinside for the PR.

This changes the signature of the API and will require a version change.

Can you update the new code to pass the format check as defined here https://github.com/swiftlang/github-workflows/blob/main/.github/workflows/soundness.yml#L166 ?

@sebsto sebsto added 🆕 semver/minor Adds new public API. and removed ⚠️ semver/major Breaks existing public API. labels Nov 26, 2024
@twistinside
Copy link
Author

I was seeing the same failure in soundness.sh on my mac. I attempted to run in linux today and saw it's been removed... Is there any further action you'd like from me on this PR?

@twistinside
Copy link
Author

I ran the soundness check, here's the output:

(main) $ ./check-swift-format.sh 
** Running swift format format...
** Running swift format lint...
** Checking for modified files...
** ✅ Found no formatting issues.

@sebsto sebsto closed this Dec 3, 2024
sebsto added a commit that referenced this pull request Dec 3, 2024
Add custom Decodable conformance.
Closes #73
Duplicate of
#76 created
by @twistinside

**Motivation:**
Absent collections would fail to decode, when in reality it is possible
to have empty headers, for example. This allows processing to continue
in the context of the Lambda runtime where users can handle the
collections as dictated by their code.

**Modifications:**
Custom Decodable conformance has been added to both API Gateway request
objects to optionally decode absent collections to empty collections.

Unit testa have been added for the same.

**Result:**
This will make the swift lambda runtime more accepting of input,
allowing processing to proceed in the rare cases where collection fields
would be absent in the JSON received by the runtime. This will unlock
certain functionality in edge cases such as testing lambda code from API
Gateway console with empty headers (the use case that prompted this
change).

This change will require users to update their code to remove optional
handling for the collections involved, potentially also requiring extra
logic to validate that the collections they've received aren't empty.

---------

Authored-by: twistinside <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🆕 semver/minor Adds new public API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider optional headers for APIGatewayRequest
3 participants