oscerd opened a new pull request, #26679:
URL: https://github.com/apache/camel/pull/26679

   This fixes [CAMEL-24740](https://issues.apache.org/jira/browse/CAMEL-24740).
   
   A route that splits a payload and authorizes each element paid one OPA 
round-trip per element. The producer now takes a **`batch`** option: with 
`batch=true` and a `List` body it builds one input document per element — each 
element as the `body`, sharing the exchange's headers and properties — and 
evaluates them in a single call through OPA's batch API 
(`OPAClient.evaluateBatch`, which the SDK falls back to sequential requests for 
when the server doesn't implement the endpoint).
   
   **Result contract.** Per-element verdicts arrive in a new header 
**`CamelOpaBatchDecision`** — a `List<Boolean>` parallel to the input. 
`CamelOpaDecisionAllow` is not set in batch mode (there's no single verdict). 
The header is cleared on entry and withheld from the OPA input like the other 
decision headers, so a sender can't preload it.
   
   **Fail-closed is per element** — the part the issue flags as "not 
mechanical": an element whose evaluation could not be reached is denied, or 
allowed under `failOpen`, while the others decide normally. The batch is never 
denied wholesale because one element failed, nor allowed because most 
succeeded. Only a call that fails *entirely* (server unreachable) denies every 
element (or, under `failOpen`, allows them).
   
   **REST-only.** Batch saves the per-element HTTP round-trip, which has no 
meaning for in-process `wasm`, so `batch` + `evaluationMode=wasm` is rejected 
at startup; the base evaluator's default `evaluateBatchDecisions` refuses, so 
the WASM engine inherits it.
   
   **Design choices flagged for review** (new public API): a bare 
`List<Boolean>` result header (not a per-element decision *object* — the raw 
docs aren't retained for batch); each element as the `body` slot of its input 
(reusing `includeHeaders`/`includeProperties`); an explicit `batch` opt-in 
rather than inferring from a `List` body. Happy to adjust any of these.
   
   **Tests** (`OpaBatchEvaluationTest`, mocked `OPAClient`): parallel verdicts; 
a failed element denied while its neighbours decide; the same element allowed 
under `failOpen`; the List-body requirement; and the WASM rejection.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
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]

Reply via email to