gnodet-bot commented on code in PR #26445:
URL: https://github.com/apache/camel/pull/26445#discussion_r4009044658
##########
components/camel-opa/src/main/java/org/apache/camel/component/opa/OpaEndpoint.java:
##########
@@ -57,16 +60,40 @@ public OpaEndpoint(final String uri, final Component
component, final OpaConfigu
@Override
protected void doStart() throws Exception {
super.doStart();
- opaClient = configuration.getOpaClient() != null
- ? configuration.getOpaClient()
- :
OpaPolicyEvaluator.createClient(configuration.getServerUrl(),
configuration.getBearerToken());
- evaluator = new OpaPolicyEvaluator(
- opaClient, policyPath, configuration.getAllowKey(),
configuration.getIncludeHeaders(),
- configuration.getIncludeProperties(),
configuration.isIncludeBody(), configuration.isFailOpen());
+ if (WASM_MODE.equalsIgnoreCase(configuration.getEvaluationMode())) {
+ evaluator = createWasmEvaluator();
+ } else {
Review Comment:
⚠️ **Invalid `evaluationMode` silently falls through to REST.** If someone
typos `evaluationMode=WASM2` or `evaluationMode=grpc`, the `else` branch
creates a REST evaluator with no warning. The user gets a working endpoint that
ignores their `policyBundle` config entirely — hard to debug in production.
Validate the mode and fail fast:
```suggestion
if (WASM_MODE.equalsIgnoreCase(configuration.getEvaluationMode())) {
evaluator = createWasmEvaluator();
} else if
("rest".equalsIgnoreCase(configuration.getEvaluationMode()) ||
ObjectHelper.isEmpty(configuration.getEvaluationMode())) {
```
--
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]