Skip to content

CAMEL-24354: camel-aws2-lambda - updateFunction never sets the code source, so UpdateFunctionCode always fails - #25343

Merged
oscerd merged 1 commit into
apache:mainfrom
oscerd:fix/CAMEL-24354
Aug 5, 2026
Merged

CAMEL-24354: camel-aws2-lambda - updateFunction never sets the code source, so UpdateFunctionCode always fails#25343
oscerd merged 1 commit into
apache:mainfrom
oscerd:fix/CAMEL-24354

Conversation

@oscerd

@oscerd oscerd commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

CAMEL-24354: camel-aws2-lambda — updateFunction never sent the code source

Problem

Lambda2Producer.updateFunction() built an UpdateFunctionCodeRequest that only ever carried functionName and (optionally) publish. In the default (non-pojoRequest) branch it validated that a message body, CamelAwsLambdaS3Bucket, or CamelAwsLambdaS3Key was present — and then discarded them. It never called zipFile(..), s3Bucket(..), s3Key(..) or s3ObjectVersion(..) on the builder.

AWS UpdateFunctionCode requires exactly one code source (ZipFile, or S3Bucket+S3Key, or ImageUri). The request built here had none, so every call was rejected with:

InvalidParameterValueException: Please provide a source for function code.

The updateFunction operation was therefore unusable in the default mode. (pojoRequest=true is 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.Builder from the same headers/body as createFunction:

  • CamelAwsLambdaS3Buckets3Bucket
  • CamelAwsLambdaS3Keys3Key
  • CamelAwsLambdaS3ObjectVersions3ObjectVersion
  • CamelAwsLambdaZipFile (local file path) → zipFile
  • message body → zipFile

and include the ZIP_FILE header 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 the UpdateFunctionCodeRequest) asserting the request carries the code source (zipFile() non-null) — it fails against the pre-fix code. Full LambdaProducerTest green (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

… 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>
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

🌟 Thank you for your contribution to the Apache Camel project! 🌟
🤖 CI automation will test this PR automatically.

🐫 Apache Camel Committers, please review the following items:

  • First-time contributors require MANUAL approval for the GitHub Actions to run
  • You can use the command /component-test (camel-)component-name1 (camel-)component-name2.. to request a test from the test bot although they are normally detected and executed by CI.
  • You can label PRs using skip-tests and test-dependents to fine-tune the checks executed by this PR.
  • Build and test logs are available in the summary page. Only Apache Camel committers have access to the summary.

⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Correct, well-targeted bug fix for a completely broken updateFunction operation that has been unusable since 2020.

What the fix does:

  • The updateFunction operation never assembled the code source (FunctionCodeLocation) — it was missing the S3 bucket/key/object-version mapping and the ZIP_FILE/body-as-ByteBuffer handling. The UpdateFunctionCode API call always failed because no code source was provided.
  • The fix correctly mirrors the proven createFunction code-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 deleteEventSourceMapping error message typo ("Event Source Arn" → "Event Source UUID"), which is correct since the code validates Lambda2Constants.EVENT_SOURCE_UUID and calls builder.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

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • components/camel-aws/camel-aws2-lambda

🔬 Scalpel shadow comparison — Scalpel: 9 tested, 29 compile-only — current: 9 all tested

Maveniverse Scalpel detected 38 affected modules (current approach: 9).

⚠️ Modules only in Scalpel (29)
  • apache-camel
  • camel-allcomponents
  • camel-catalog
  • camel-catalog-console
  • camel-catalog-lucene
  • camel-catalog-maven
  • camel-catalog-suggest
  • camel-componentdsl
  • camel-csimple-maven-plugin
  • camel-endpointdsl
  • camel-endpointdsl-support
  • camel-itest
  • camel-jbang-core
  • camel-jbang-it
  • camel-jbang-main
  • camel-jbang-plugin-edit
  • camel-jbang-plugin-generate
  • camel-jbang-plugin-kubernetes
  • camel-jbang-plugin-test
  • camel-kamelet-main
  • camel-launcher
  • camel-report-maven-plugin
  • camel-route-parser
  • camel-yaml-dsl
  • camel-yaml-dsl-deserializers
  • camel-yaml-dsl-maven-plugin
  • coverage
  • docs
  • dummy-component

Skip-tests mode would test 9 modules (1 direct + 8 downstream), skip tests for 29 (generated code, meta-modules)

Modules Scalpel would test (9)
  • camel-aws2-lambda
  • camel-jbang-mcp
  • camel-jbang-plugin-mcp
  • camel-jbang-plugin-route-parser
  • camel-jbang-plugin-tui
  • camel-jbang-plugin-validate
  • camel-launcher-container
  • camel-yaml-dsl-validator
  • camel-yaml-dsl-validator-maven-plugin
Modules with tests skipped (29)
  • apache-camel
  • camel-allcomponents
  • camel-catalog
  • camel-catalog-console
  • camel-catalog-lucene
  • camel-catalog-maven
  • camel-catalog-suggest
  • camel-componentdsl
  • camel-csimple-maven-plugin
  • camel-endpointdsl
  • camel-endpointdsl-support
  • camel-itest
  • camel-jbang-core
  • camel-jbang-it
  • camel-jbang-main
  • camel-jbang-plugin-edit
  • camel-jbang-plugin-generate
  • camel-jbang-plugin-kubernetes
  • camel-jbang-plugin-test
  • camel-kamelet-main
  • camel-launcher
  • camel-report-maven-plugin
  • camel-route-parser
  • camel-yaml-dsl
  • camel-yaml-dsl-deserializers
  • camel-yaml-dsl-maven-plugin
  • coverage
  • docs
  • dummy-component

ℹ️ Shadow mode — Scalpel observes but does not affect test execution. Learn more

All tested modules (38 modules)
  • Camel :: AWS2 Lambda
  • Camel :: All Components Sync point
  • Camel :: Assembly
  • Camel :: Catalog :: CSimple Maven Plugin (deprecated)
  • Camel :: Catalog :: Camel Catalog
  • Camel :: Catalog :: Camel Report Maven Plugin
  • Camel :: Catalog :: Camel Route Parser
  • Camel :: Catalog :: Console
  • Camel :: Catalog :: Dummy Component
  • Camel :: Catalog :: Lucene (deprecated)
  • Camel :: Catalog :: Maven
  • Camel :: Catalog :: Suggest
  • Camel :: Component DSL
  • Camel :: Coverage
  • Camel :: Docs
  • Camel :: Endpoint DSL
  • Camel :: Endpoint DSL :: Support
  • Camel :: Integration Tests
  • Camel :: JBang :: Core
  • Camel :: JBang :: Integration tests
  • Camel :: JBang :: MCP
  • Camel :: JBang :: Main
  • Camel :: JBang :: Plugin :: Edit
  • Camel :: JBang :: Plugin :: Generate
  • Camel :: JBang :: Plugin :: Kubernetes
  • Camel :: JBang :: Plugin :: MCP
  • Camel :: JBang :: Plugin :: Route Parser
  • Camel :: JBang :: Plugin :: TUI
  • Camel :: JBang :: Plugin :: Testing
  • Camel :: JBang :: Plugin :: Validate
  • Camel :: Kamelet Main
  • Camel :: Launcher
  • Camel :: Launcher :: Container
  • Camel :: YAML DSL
  • Camel :: YAML DSL :: Deserializers
  • Camel :: YAML DSL :: Maven Plugins
  • Camel :: YAML DSL :: Validator
  • Camel :: YAML DSL :: Validator Maven Plugin

⚙️ View full build and test results

@oscerd
oscerd merged commit cad87f1 into apache:main Aug 5, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working components components-aws

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants