Skip to content

CAMEL-24262: camel-aws2 - guard nullable awsErrorDetails() when logging the AWS error code in producer catch blocks - #25324

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

CAMEL-24262: camel-aws2 - guard nullable awsErrorDetails() when logging the AWS error code in producer catch blocks#25324
oscerd merged 1 commit into
apache:mainfrom
oscerd:fix/CAMEL-24262

Conversation

@oscerd

@oscerd oscerd commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

CAMEL-24262: guard nullable awsErrorDetails() when logging the AWS error code

Motivation

software.amazon.awssdk.awscore.exception.AwsServiceException#awsErrorDetails() is nullable. Across the camel-aws producers, catch blocks log the AWS error code like this:

} catch (AwsServiceException ase) {
    LOG.trace("getFunction command returned the error code {}", ase.awsErrorDetails().errorCode());
    throw ase;
}

Because a method argument is evaluated eagerly, regardless of the configured log level, ase.awsErrorDetails().errorCode() runs even when TRACE/DEBUG is disabled. When awsErrorDetails() returns null (e.g. connection/SDK-level failures that are not a modeled service error), this throws a NullPointerException from inside the catch block, masking the original AWS exception that was about to be rethrown.

Fix

  • Add a small null-safe helper AwsExceptionUtil.errorCode(AwsServiceException) in camel-aws-common (returns null when the exception or its awsErrorDetails() is absent).
  • Route every producer catch-block error-code log statement across the camel-aws components through it, replacing x.awsErrorDetails().errorCode() with AwsExceptionUtil.errorCode(x).

This is a defensive robustness fix: behaviour is unchanged on the happy path (the real error code is still logged), but a null awsErrorDetails can no longer shadow the underlying exception.

Scope

  • New: AwsExceptionUtil + unit test in camel-aws-common.
  • 28 producers updated across 25 camel-aws modules (bedrock, comprehend, config, ec2, ecs, eks, eventbridge, iam, kinesis-firehose, kms, lambda, mq, msk, parameter-store, polly, redshift-data, rekognition, secrets-manager, security-hub, step-functions, sts, textract, timestream, transcribe, translate).
  • The *ProducerHealthCheck classes already guard this inline (CAMEL-24251) and are untouched.

No public API change, no new dependency (the helper lives in the shared camel-aws-common that every producer already depends on).

Testing

  • New hermetic unit test AwsExceptionUtilTest (3 cases: error code present, awsErrorDetails absent → null, null exception → null) — no LocalStack / real AWS.
  • Full reactor mvn clean install -Dquickly is green.

Only targeting main (4.22.0) — low-severity, non-behavioural hardening.


🤖 Generated with Claude Code

…ng the AWS error code in producer catch blocks

AwsServiceException.awsErrorDetails() is nullable, so producer catch-block
log statements of the form LOG.trace("...{}", e.awsErrorDetails().errorCode())
can throw a NullPointerException that masks the original AWS exception - the
argument is evaluated eagerly regardless of the configured log level.

Add a small AwsExceptionUtil.errorCode(AwsServiceException) helper in
camel-aws-common that reads the error code defensively (null-safe on both the
exception and its awsErrorDetails), and route all producer catch-block
error-code logging across the camel-aws components through it.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Andrea Cosentino <ancosen@gmail.com>
@oscerd
oscerd requested review from Croway and davsclaus August 4, 2026 10:42
@oscerd oscerd added the bug Something isn't working label Aug 4, 2026
@oscerd oscerd added this to the 4.22.0 milestone Aug 4, 2026
@github-actions

github-actions Bot commented Aug 4, 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.

@oscerd oscerd self-assigned this Aug 4, 2026
@oscerd
oscerd merged commit 99641e9 into apache:main Aug 4, 2026
5 checks passed
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • components/camel-aws/camel-aws-bedrock
  • components/camel-aws/camel-aws-common
  • components/camel-aws/camel-aws-config
  • components/camel-aws/camel-aws-parameter-store
  • components/camel-aws/camel-aws-secrets-manager
  • components/camel-aws/camel-aws-security-hub
  • components/camel-aws/camel-aws2-comprehend
  • components/camel-aws/camel-aws2-ec2
  • components/camel-aws/camel-aws2-ecs
  • components/camel-aws/camel-aws2-eks
  • components/camel-aws/camel-aws2-eventbridge
  • components/camel-aws/camel-aws2-iam
  • components/camel-aws/camel-aws2-kinesis
  • components/camel-aws/camel-aws2-kms
  • components/camel-aws/camel-aws2-lambda
  • components/camel-aws/camel-aws2-mq
  • components/camel-aws/camel-aws2-msk
  • components/camel-aws/camel-aws2-polly
  • components/camel-aws/camel-aws2-redshift
  • components/camel-aws/camel-aws2-rekognition
  • components/camel-aws/camel-aws2-step-functions
  • components/camel-aws/camel-aws2-sts
  • components/camel-aws/camel-aws2-textract
  • components/camel-aws/camel-aws2-timestream
  • components/camel-aws/camel-aws2-transcribe
  • components/camel-aws/camel-aws2-translate

ℹ️ Dependent modules were not tested because the total number of affected modules exceeded the threshold (50). Use the test-dependents label to force testing all dependents.


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

Maveniverse Scalpel detected 72 affected modules (current approach: 43).

⚠️ 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 43 modules (26 direct + 17 downstream), skip tests for 29 (generated code, meta-modules)

Modules Scalpel would test (43)
  • camel-aws-bedrock
  • camel-aws-cloudtrail
  • camel-aws-common
  • camel-aws-config
  • camel-aws-parameter-store
  • camel-aws-secrets-manager
  • camel-aws-security-hub
  • camel-aws2-athena
  • camel-aws2-comprehend
  • camel-aws2-cw
  • camel-aws2-ddb
  • camel-aws2-ec2
  • camel-aws2-ecs
  • camel-aws2-eks
  • camel-aws2-eventbridge
  • camel-aws2-iam
  • camel-aws2-kinesis
  • camel-aws2-kms
  • camel-aws2-lambda
  • camel-aws2-mq
  • camel-aws2-msk
  • camel-aws2-polly
  • camel-aws2-redshift
  • camel-aws2-rekognition
  • camel-aws2-s3
  • camel-aws2-s3-vectors
  • camel-aws2-ses
  • camel-aws2-sns
  • camel-aws2-sqs
  • camel-aws2-step-functions
  • camel-aws2-sts
  • camel-aws2-textract
  • camel-aws2-timestream
  • camel-aws2-transcribe
  • camel-aws2-translate
  • 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

Build reactor — dependencies compiled but only changed modules were tested (72 modules)
  • Camel :: AWS :: Common
  • Camel :: AWS CloudTrail
  • Camel :: AWS Config
  • Camel :: AWS Redshift Data
  • Camel :: AWS Rekognition
  • Camel :: AWS Security Hub
  • Camel :: AWS Step Functions
  • Camel :: AWS Timestream
  • Camel :: AWS2 :: Transcribe
  • Camel :: AWS2 Athena
  • Camel :: AWS2 Bedrock
  • Camel :: AWS2 CW
  • Camel :: AWS2 Comprehend
  • Camel :: AWS2 DDB
  • Camel :: AWS2 EC2
  • Camel :: AWS2 ECS
  • Camel :: AWS2 EKS
  • Camel :: AWS2 Eventbridge
  • Camel :: AWS2 IAM
  • Camel :: AWS2 KMS
  • Camel :: AWS2 Kinesis
  • Camel :: AWS2 Lambda
  • Camel :: AWS2 MQ
  • Camel :: AWS2 MSK
  • Camel :: AWS2 Parameter Store
  • Camel :: AWS2 Polly
  • Camel :: AWS2 S3
  • Camel :: AWS2 S3 Vectors
  • Camel :: AWS2 SES
  • Camel :: AWS2 SNS
  • Camel :: AWS2 SQS
  • Camel :: AWS2 STS
  • Camel :: AWS2 Secrets Manager
  • Camel :: AWS2 Textract
  • Camel :: AWS2 Translate
  • 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 deleted the fix/CAMEL-24262 branch August 4, 2026 13:15
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.

2 participants