From 6c409ba7dcd3658eee6fe72f1664b13f676bde1b Mon Sep 17 00:00:00 2001 From: Maxime David Date: Thu, 1 Oct 2026 11:56:53 +0000 Subject: [PATCH 1/2] fix: incorrect header name for Client Context --- src/containerized_test_runner/docker.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/containerized_test_runner/docker.py b/src/containerized_test_runner/docker.py index 3408822..d929887 100644 --- a/src/containerized_test_runner/docker.py +++ b/src/containerized_test_runner/docker.py @@ -1,4 +1,5 @@ import logging +import base64 import json import re import subprocess @@ -24,8 +25,8 @@ _request_timeout_secs = float(os.environ.get("REQUEST_TIMEOUT_SECS", "30")) REQUEST_TIMEOUT = (5, _request_timeout_secs) -# Lambda Runtime Interface header names -HEADER_CLIENT_CONTEXT = "Lambda-Runtime-Client-Context" +# Lambda Runtime Interface header names. +HEADER_CLIENT_CONTEXT = "X-Amz-Client-Context" HEADER_COGNITO_IDENTITY_ID = "Lambda-Runtime-Cognito-Identity-Id" HEADER_COGNITO_IDENTITY_POOL_ID = "Lambda-Runtime-Cognito-Identity-Pool-Id" HEADER_XRAY_TRACE = "Lambda-Runtime-XRay-Trace-Header" @@ -188,7 +189,9 @@ def _execute_single_request(self, request: Request, local_address: str) -> Union headers.update(request.headers) if request.client_context: - headers[HEADER_CLIENT_CONTEXT] = json.dumps(request.client_context) + headers[HEADER_CLIENT_CONTEXT] = base64.b64encode( + json.dumps(request.client_context).encode("utf-8") + ).decode("ascii") if request.cognito_identity: if 'cognitoIdentityId' in request.cognito_identity: headers[HEADER_COGNITO_IDENTITY_ID] = request.cognito_identity['cognitoIdentityId'] @@ -311,7 +314,9 @@ def _capture(self, headers = {} headers["Content-Type"] = request.content_type if client_context: - headers[HEADER_CLIENT_CONTEXT] = json.dumps(client_context) + headers[HEADER_CLIENT_CONTEXT] = base64.b64encode( + json.dumps(client_context).encode("utf-8") + ).decode("ascii") if 'cognitoIdentityId' in cognito_identity: headers[HEADER_COGNITO_IDENTITY_ID] = cognito_identity['cognitoIdentityId'] if 'cognitoIdentityPoolId' in cognito_identity: From 76eacfb110903739d9c5f7fcdaafede6324a1473 Mon Sep 17 00:00:00 2001 From: Maxime David Date: Thu, 1 Oct 2026 12:02:24 +0000 Subject: [PATCH 2/2] fix: add tests --- github-action-test/lambda/suite0.json | 19 +++++++++++++++++++ .../lambda/tasks/nodejs/core.mjs | 4 ++++ .../lambda/tasks/python/core.py | 6 +++++- 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/github-action-test/lambda/suite0.json b/github-action-test/lambda/suite0.json index df78a58..ff96be1 100644 --- a/github-action-test/lambda/suite0.json +++ b/github-action-test/lambda/suite0.json @@ -33,6 +33,25 @@ } } ] + }, + { + "name": "test_client_context_custom_is_delivered", + "handler": "core.echoClientContextCustom", + "request": {}, + "clientContext": { + "custom": { + "value": "hello" + } + }, + "assertions": [ + { + "response": { + "custom": { + "value": "hello" + } + } + } + ] } ] } \ No newline at end of file diff --git a/github-action-test/lambda/tasks/nodejs/core.mjs b/github-action-test/lambda/tasks/nodejs/core.mjs index 9c4b476..d67899e 100644 --- a/github-action-test/lambda/tasks/nodejs/core.mjs +++ b/github-action-test/lambda/tasks/nodejs/core.mjs @@ -3,3 +3,7 @@ export const ping = async (event) => { msg: `pong[${event.msg}]` }; }; + +export const echoClientContextCustom = async (_event, context) => { + return { custom: context.clientContext?.custom ?? null }; +}; diff --git a/github-action-test/lambda/tasks/python/core.py b/github-action-test/lambda/tasks/python/core.py index 9422417..c3dab7c 100644 --- a/github-action-test/lambda/tasks/python/core.py +++ b/github-action-test/lambda/tasks/python/core.py @@ -1,2 +1,6 @@ def ping(event, context): - return {"msg": "pong[" + event['msg'] + "]"} \ No newline at end of file + return {"msg": "pong[" + event['msg'] + "]"} + +def echoClientContextCustom(event, context): + custom = context.client_context.custom if context.client_context else None + return {"custom": custom} \ No newline at end of file