CAMEL-25279: camel-knative - a consumer without reply must not answer 204 when the exchange failed - #27308
Conversation
… 204 when the exchange failed KnativeHttpConsumer computed the error status of a failed exchange (500), but with reply=false it then always overwrote the status with 204 No Content, because the response has no body. Knative takes a 2xx answer as a delivered event, so an event whose route failed was not sent again and was lost. A failed exchange now keeps its error status; the response still has no body. CAMEL-24428 handled the same 204 overwrite for muteException with reply=true. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
davsclaus
left a comment
There was a problem hiding this comment.
LGTM. With reply=false a failed exchange now keeps its error status instead of being overwritten with 204, so Knative can redeliver the event. This is consistent with CAMEL-24428.
Nit: the other camel-knative entries in the upgrade guide are plain paragraphs without a ==== subheading. Consider the same for consistency.
Claude Code on behalf of davsclaus. This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.
|
🧪 CI tested the following changed modules:
🔬 Scalpel shadow comparison — Scalpel: 9 of 698 tested, 26 compile-only — current: 9 all testedMaveniverse Scalpel detected 9 affected modules (current approach: 9). Skip-tests mode would test 9 modules (2 direct + 8 downstream), skip tests for 26 (generated code, meta-modules) Modules Scalpel would test (9)
Modules with tests skipped (26)
All tested modules (36 modules, 5m 52s total)Total reactor time: 5m 52s
Top 20 slowest modules:
|
…agraph like the other camel-knative entries Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks. In 4881beb the entry is a plain paragraph under Claude Code on behalf of allthingssecurity |
gnodet-bot
left a comment
There was a problem hiding this comment.
Solid fix. The root cause is clear: toHttpResponse (line 249) sets 500 on a failed exchange, but when reply=false the body is always null → the old code unconditionally overwrote with 204 → Knative saw a 2xx and considered the event delivered. The guard on exchange.isFailed() is the minimal correct fix.
Verified all four code paths:
reply=false+ success → 204 ✓reply=false+ failure → 500 preserved ✓reply=true+ failure → body isbyte[0]from muteException (CAMEL-24428), takes theend(body)path, 500 preserved ✓reply=true+ success → normal reply ✓
Test covers the failure case with all three CloudEvent versions. CI green (176 tests). Upgrade guide entry is consistent with the existing === camel-knative section format.
ast-grep flagged a broad-exception-catch at line 270 — pre-existing code, not introduced by this PR.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
Description
CAMEL-25279
With
reply=falsethe Knative HTTP consumer never has a response body, and without a body it always set204 No Content, overwriting the 500 it had just computed for a failed exchange. Knative takes a 2xx answer as a delivered event, so an event whose route failed was not retried (nor sent to a dead letter sink). CAMEL-24428 fixed the same overwrite formuteExceptionwithreply=true.This change: without a body the consumer sets 204 only when the exchange did not fail; a failed exchange keeps its error status, with an empty body. The upgrade guide for 4.23 gets a short note.
Tests:
KnativeHttpTest.testNoReplyFailure(new, for the three CloudEvents versions): liketestNoReply, with a route that throws.Expected status code <500> but was <204>.Target
mainbranch)Tracking
Apache Camel coding standards and style
mvn clean install -DskipTestslocally from root folder and I have committed all auto-generated changes.(I built and tested the affected module, including the formatter and import-sort plugins. I did not run the full root build.)
AI-assisted contributions
Co-authored-bytrailers) and the PR description identifies the AI tool used.This PR was prepared with Claude Code (Claude Opus 5.5). The commit carries a
Co-Authored-Bytrailer.Claude Code on behalf of allthingssecurity
🤖 Generated with Claude Code