CAMEL-24354: camel-aws2-lambda - updateFunction never sets the code source, so UpdateFunctionCode always fails - #25343
Conversation
… so UpdateFunctionCode no longer fails Lambda2Producer.updateFunction() built an UpdateFunctionCodeRequest that only ever carried functionName and (optionally) publish: it validated that a body, S3 bucket, or S3 key was present and then discarded them, never setting zipFile/s3Bucket/s3Key/s3ObjectVersion. AWS UpdateFunctionCode requires a code source, so every call failed with InvalidParameterValueException and the operation was unusable in the default (non-pojoRequest) mode. Assemble the code source on the request builder from the same headers/body as createFunction (S3 bucket/key/object-version, the ZIP_FILE header path, and the message body), and add a test asserting the request carries it. Also corrects deleteEventSourceMapping's validation message, which read "Event Source Arn must be specified" although it validates the event source mapping UUID. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Andrea Cosentino <ancosen@gmail.com>
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
gnodet
left a comment
There was a problem hiding this comment.
Correct, well-targeted bug fix for a completely broken updateFunction operation that has been unusable since 2020.
What the fix does:
- The
updateFunctionoperation never assembled the code source (FunctionCodeLocation) — it was missing the S3 bucket/key/object-version mapping and the ZIP_FILE/body-as-ByteBuffer handling. TheUpdateFunctionCodeAPI call always failed because no code source was provided. - The fix correctly mirrors the proven
createFunctioncode-source assembly pattern, which is the right approach for consistency and correctness. - The new test verifies the key property (zip file content reaching the request) by capturing the request payload in the mock — closing the gap that let this bug survive since 2020.
- Bonus: fixes a
deleteEventSourceMappingerror message typo ("Event Source Arn" → "Event Source UUID"), which is correct since the code validatesLambda2Constants.EVENT_SOURCE_UUIDand callsbuilder.uuid(...).
Minor convention note: the new test method uses public visibility and JUnit assertions, consistent with the existing file but not with current project conventions (package-private visibility + AssertJ preferred for new code). Not blocking — consistency within the file is reasonable here.
This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.
Claude Code on behalf of @gnodet
|
🧪 CI tested the following changed modules:
🔬 Scalpel shadow comparison — Scalpel: 9 tested, 29 compile-only — current: 9 all testedMaveniverse Scalpel detected 38 affected modules (current approach: 9).
|
CAMEL-24354: camel-aws2-lambda —
updateFunctionnever sent the code sourceProblem
Lambda2Producer.updateFunction()built anUpdateFunctionCodeRequestthat only ever carriedfunctionNameand (optionally)publish. In the default (non-pojoRequest) branch it validated that a message body,CamelAwsLambdaS3Bucket, orCamelAwsLambdaS3Keywas present — and then discarded them. It never calledzipFile(..),s3Bucket(..),s3Key(..)ors3ObjectVersion(..)on the builder.AWS
UpdateFunctionCoderequires exactly one code source (ZipFile, or S3Bucket+S3Key, or ImageUri). The request built here had none, so every call was rejected with:The
updateFunctionoperation was therefore unusable in the default mode. (pojoRequest=trueis unaffected — the caller supplies a complete request.) It went unnoticed because no unit test invoked the operation and the test mock echoed only the function name.Fix
Assemble the code source on the
UpdateFunctionCodeRequest.Builderfrom the same headers/body ascreateFunction:CamelAwsLambdaS3Bucket→s3BucketCamelAwsLambdaS3Key→s3KeyCamelAwsLambdaS3ObjectVersion→s3ObjectVersionCamelAwsLambdaZipFile(local file path) →zipFilezipFileand include the
ZIP_FILEheader in the "no source specified" validation.Also corrects a copy-paste in
deleteEventSourceMapping(): the validation reads the event source mapping UUID header but threw"Event Source Arn must be specified"— the message now says UUID.Test
Adds
LambdaProducerTest.lambdaUpdateFunctionTest(the mock now captures theUpdateFunctionCodeRequest) asserting the request carries the code source (zipFile()non-null) — it fails against the pre-fix code. FullLambdaProducerTestgreen (32 tests).No public API change, no new dependency. Affects
main(4.22.0) and the 4.18.x / 4.14.x lines.🤖 Generated with Claude Code