Skip to content

CAMEL-25279: camel-knative - a consumer without reply must not answer 204 when the exchange failed - #27308

Merged
davsclaus merged 2 commits into
apache:mainfrom
allthingssecurity:camel-knative-no-reply-failure
Oct 3, 2026
Merged

davsclaus merged 2 commits into
apache:mainfrom
allthingssecurity:camel-knative-no-reply-failure

Conversation

@allthingssecurity

Copy link
Copy Markdown
Contributor

Description

CAMEL-25279

With reply=false the Knative HTTP consumer never has a response body, and without a body it always set 204 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 for muteException with reply=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): like testNoReply, with a route that throws.
  • Without the change it fails: Expected status code <500> but was <204>.
  • With the change all camel-knative-http tests pass: 176 tests, 0 failures.

Target

  • I checked that the commit is targeting the correct branch (Camel 4 uses the main branch)

Tracking

  • If this is a large change, bug fix, or code improvement, I checked there is a JIRA issue filed for the change (usually before you start working on it).

Apache Camel coding standards and style

  • I checked that each commit in the pull request has a meaningful subject line and body.
  • I have run mvn clean install -DskipTests locally 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

  • If this PR includes AI-generated code, commits have proper co-authorship attribution (e.g., Co-authored-by trailers) 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-By trailer.

Claude Code on behalf of allthingssecurity

🤖 Generated with Claude Code

… 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>
@github-actions

github-actions Bot commented Oct 3, 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.

@davsclaus davsclaus left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • components/camel-knative/camel-knative-http
  • docs

🔬 Scalpel shadow comparison — Scalpel: 9 of 698 tested, 26 compile-only — current: 9 all tested

Maveniverse 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)
  • camel-jbang-mcp ← downstream of org.apache.camel:camel-catalog
  • camel-jbang-plugin-mcp ← downstream of org.apache.camel:camel-jbang-core
  • camel-jbang-plugin-route-parser ← downstream of org.apache.camel:camel-route-parser
  • camel-jbang-plugin-tui ← downstream of org.apache.camel:camel-catalog
  • camel-jbang-plugin-validate ← downstream of org.apache.camel:camel-yaml-dsl-validator
  • camel-knative-http ← components/camel-knative/camel-knative-http/src/main/java/org/apache/camel/component/knative/http/KnativeHttpConsumer.java, components/camel-knative/camel-knative-http/src/test/java/org/apache/camel/component/knative/http/KnativeHttpTest.java
  • camel-launcher-container ← downstream of org.apache.camel:camel-launcher
  • camel-yaml-dsl-validator ← downstream of org.apache.camel:camel-catalog
  • camel-yaml-dsl-validator-maven-plugin ← downstream of org.apache.camel:camel-yaml-dsl-validator
Modules with tests skipped (26)
  • apache-camel
  • camel-allcomponents
  • camel-catalog
  • camel-catalog-console
  • camel-catalog-maven
  • camel-catalog-suggest
  • camel-componentdsl
  • 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
  • dummy-component

ℹ️ Shadow mode — Scalpel observes but does not affect test execution. Learn more

All tested modules (36 modules, 5m 52s total)

Total reactor time: 5m 52s

Module Duration Status
Camel :: Launcher 47.1s SUCCESS
Camel :: JBang :: Plugin :: TUI 39.8s SUCCESS
Camel :: JBang :: MCP 37.5s SUCCESS
Camel :: Knative HTTP 34.0s SUCCESS
Camel :: Component DSL 22.8s SUCCESS
Camel :: Catalog :: Camel Catalog 21.6s SUCCESS
Camel :: YAML DSL :: Validator 19.5s SUCCESS
Camel :: YAML DSL 18.4s SUCCESS
Camel :: JBang :: Plugin :: Kubernetes 17.0s SUCCESS
Camel :: Kamelet Main 12.4s SUCCESS
Camel :: Docs 11.8s SUCCESS
Camel :: YAML DSL :: Deserializers 8.2s SUCCESS
Camel :: JBang :: Plugin :: Testing 7.6s SUCCESS
Camel :: Catalog :: Camel Route Parser 7.3s SUCCESS
Camel :: YAML DSL :: Validator Maven Plugin 7.2s SUCCESS
Camel :: Catalog :: Camel Report Maven Plugin 7.2s SUCCESS
Camel :: JBang :: Plugin :: Validate 5.5s SUCCESS
Camel :: All Components Sync point 5.3s SUCCESS
Camel :: Catalog :: Maven 3.2s SUCCESS
Camel :: YAML DSL :: Maven Plugins 3.1s SUCCESS
Camel :: Catalog :: Suggest (deprecated) 2.5s SUCCESS
Camel :: Catalog :: Dummy Component 2.5s SUCCESS
Camel :: Assembly 1.6s SUCCESS
Camel :: JBang :: Plugin :: Edit 1.5s SUCCESS
Camel :: Coverage 1.4s SUCCESS
Camel :: JBang :: Plugin :: Generate 1.2s SUCCESS
Camel :: JBang :: Integration tests 0.9s SUCCESS
Camel :: Catalog :: Console 0.9s SUCCESS
Camel :: JBang :: Main 0.8s SUCCESS
Camel :: Endpoint DSL :: Support 0.7s SUCCESS
Camel :: Launcher :: Container 0.7s SUCCESS
Camel :: JBang :: Plugin :: MCP 0.6s SUCCESS
Camel :: JBang :: Plugin :: Route Parser 0.5s SUCCESS
Camel :: Endpoint DSL n/a
Camel :: Integration Tests n/a
Camel :: JBang :: Core n/a

Top 20 slowest modules:

  • Camel :: Launcher (47.1s)
  • Camel :: JBang :: Plugin :: TUI (39.8s)
  • Camel :: JBang :: MCP (37.5s)
  • Camel :: Knative HTTP (34.0s)
  • Camel :: Component DSL (22.8s)
  • Camel :: Catalog :: Camel Catalog (21.6s)
  • Camel :: YAML DSL :: Validator (19.5s)
  • Camel :: YAML DSL (18.4s)
  • Camel :: JBang :: Plugin :: Kubernetes (17.0s)
  • Camel :: Kamelet Main (12.4s)
  • Camel :: Docs (11.8s)
  • Camel :: YAML DSL :: Deserializers (8.2s)
  • Camel :: JBang :: Plugin :: Testing (7.6s)
  • Camel :: Catalog :: Camel Route Parser (7.3s)
  • Camel :: YAML DSL :: Validator Maven Plugin (7.2s)
  • Camel :: Catalog :: Camel Report Maven Plugin (7.2s)
  • Camel :: JBang :: Plugin :: Validate (5.5s)
  • Camel :: All Components Sync point (5.3s)
  • Camel :: Catalog :: Maven (3.2s)
  • Camel :: YAML DSL :: Maven Plugins (3.1s)

⚙️ View full build and test results

…agraph like the other camel-knative entries

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@allthingssecurity

Copy link
Copy Markdown
Contributor Author

Thanks. In 4881beb the entry is a plain paragraph under === camel-knative, without the ==== subheading. It has a one-line lead sentence and then the details, like the muteException and TLS trust entries above it. This is a doc-only change.

Claude Code on behalf of allthingssecurity

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 is byte[0] from muteException (CAMEL-24428), takes the end(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.

@davsclaus davsclaus added this to the 4.23.0 milestone Oct 3, 2026
@davsclaus davsclaus added the bug Something isn't working label Oct 3, 2026
@davsclaus
davsclaus merged commit 91bae2d into apache:main Oct 3, 2026
7 checks passed
@allthingssecurity
allthingssecurity deleted the camel-knative-no-reply-failure branch October 3, 2026 08:34
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 docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants