Skip to content

Use a struct for ClientContext (fix #169) #539

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

sebsto
Copy link
Contributor

@sebsto sebsto commented Jul 31, 2025

Do not use a String for Lambdacontext.ClientContext, use a struct instead
fix for #169

Note: this PR introduces an API change that will break function using LambdaContext, we should integrate this change during the beta otherwise it will require a major version bump.

Motivation:

Let the compiler detect type errors for us

Modifications:

  • Create a struct for ClientContext and it's embedded ClientApplication
  • add three unit test to validate the struct

Result:

No more String?

@sebsto sebsto added this to the 2.0 milestone Jul 31, 2025
@sebsto sebsto requested a review from Copilot July 31, 2025 05:29
@sebsto sebsto self-assigned this Jul 31, 2025
@sebsto sebsto added the 🆕 semver/minor Adds new public API. label Jul 31, 2025
Copy link
Contributor

@Copilot 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

This PR replaces the string-based ClientContext implementation with strongly-typed structs to provide better type safety and compiler error detection for AWS Lambda runtime client context data.

  • Replaces String? type with structured ClientContext and ClientApplication types
  • Adds proper JSON encoding/decoding with snake_case field mapping for AWS compatibility
  • Includes comprehensive unit tests covering various ClientContext scenarios

Reviewed Changes

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

File Description
Sources/AWSLambdaRuntime/LambdaContext.swift Introduces ClientContext and ClientApplication structs with proper Codable implementation and updates LambdaContext to use the new types
Tests/AWSLambdaRuntimeTests/LambdaContextTests.swift Adds comprehensive test suite covering JSON encoding/decoding scenarios for the new ClientContext types

@sebsto sebsto requested a review from ktoso July 31, 2025 15:05
@sebsto
Copy link
Contributor Author

sebsto commented Jul 31, 2025

Hello @ktoso
This is the oldest open issue on this project
#169

You opened it 5 years ago :-)
Can you review the change, and provide feedback or approve it ?

Thanks

@sebsto sebsto added ⚠️ semver/major Breaks existing public API. and removed 🆕 semver/minor Adds new public API. labels Jul 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⚠️ semver/major Breaks existing public API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant