oscerd opened a new pull request, #23151: URL: https://github.com/apache/camel/pull/23151
## Summary Issue: [CAMEL-23461](https://issues.apache.org/jira/browse/CAMEL-23461) The `applyGuardrail` producer operation in `camel-aws-bedrock` reads the guardrail identifier from the `CamelAwsBedrockGuardrailConfig` header as a `String`: ```java // BedrockProducer.java (before) String guardrailIdentifier = exchange.getMessage().getHeader(BedrockConstants.GUARDRAIL_CONFIG, String.class); ``` However, `GUARDRAIL_CONFIG` is documented in `BedrockConstants` as a `GuardrailConfiguration` and is consumed as such by the `converse` / `converseStream` operations. When a route uses both `converse` and `applyGuardrail`, the same header carries two incompatible types — the cast silently produces `null` and the operation falls back to the endpoint configuration only. ### Fix * Add a dedicated header `CamelAwsBedrockGuardrailIdentifier` (`BedrockConstants.GUARDRAIL_IDENTIFIER`, typed `String`) for the `applyGuardrail` operation. * `applyGuardrail` now reads the identifier from `GUARDRAIL_IDENTIFIER`; the endpoint-level `guardrailIdentifier` option still acts as the fallback. * `GUARDRAIL_CONFIG` remains reserved for `converse` / `converseStream` (`GuardrailConfiguration` / `GuardrailStreamConfiguration`) — no behavior change for those operations. ### Tests New unit test `BedrockApplyGuardrailTest` (mocked `BedrockRuntimeClient`, no AWS access required) covers four scenarios: * Identifier resolved from endpoint configuration when no header is set * Identifier resolved from the new `GUARDRAIL_IDENTIFIER` header * `GUARDRAIL_CONFIG` header carrying a `GuardrailConfiguration` does **not** corrupt the `applyGuardrail` request (regression guard for the original bug) * Producer fails with a clear error message when no identifier is provided ### Other changes * `aws-bedrock-component.adoc`: documented the new message-level header. * `camel-4x-upgrade-guide-4_21.adoc`: brief note describing the new header for users mixing operations. * Regenerated catalog/metadata/endpoint-DSL files for the new constant. ## Test plan - [x] `mvn test` in `components/camel-aws/camel-aws-bedrock` (94 tests pass, including 4 new ones) - [x] `mvn clean install -DskipTests` from the repo root (full reactor build succeeds) --- _Claude Code on behalf of Andrea Cosentino._ -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
