Skip to content

CAMEL-24115: camel-rest-openapi - Write generated operationId back to Operation for dispatch#24781

Merged
davsclaus merged 1 commit into
mainfrom
fix/CAMEL-24115
Jul 16, 2026
Merged

CAMEL-24115: camel-rest-openapi - Write generated operationId back to Operation for dispatch#24781
davsclaus merged 1 commit into
mainfrom
fix/CAMEL-24115

Conversation

@davsclaus

Copy link
Copy Markdown
Contributor

Summary

Claude Code on behalf of davsclaus

When an OpenAPI spec has operations without operationId, validateOpenApi() correctly generates synthetic IDs (GENOPID_<VERB><sanitized_path>) and validates against them. However, the generated ID was never written back to the Operation object, so process() called operation.getOperationId() which returned null, dispatching every request to direct:null instead of the generated endpoint.

Fix: Write the generated operationId back to the Operation object in validateOpenApi(), so both validation and runtime dispatch use the same ID.

Failure scenario (before fix):

  • Spec with GET /users and no operationId
  • missingOperation=fail: startup tells user to add direct:GENOPID_GET.users; user adds it; validation passes; every request resolves direct:nullDirectConsumerNotAvailableException → HTTP 500
  • missingOperation=mock/ignore: user-defined GENOPID route is silently never invoked

Test plan

  • New test testMissingOperationIdSetsGeneratedIdOnOperation verifies operationIds are written back after validation
  • Existing test testMissingOperationId still passes (validation error message unchanged)
  • All 135 tests in camel-rest-openapi pass
  • CI validates no regressions

🤖 Generated with Claude Code

… Operation for dispatch

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>
@davsclaus
davsclaus requested review from Croway and gnodet July 16, 2026 10:21
@github-actions

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.

@gnodet gnodet 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 — clear bug fix for null operationId dispatch.

Verification:

  • Confirmed process() dispatches via operation.getOperationId() (lines 203 and 252), resolving to direct:null when the generated ID wasn't written back.
  • The fix is minimal and correct: op.setOperationId(id) persists the generated ID so both validateOpenApi() and process() use the same value.
  • The generateOperationId() method (path sanitization: /., {}_, prefix GENOPID_<VERB>) is unchanged and already well-tested by testMissingOperationId.
  • The new test cleanly verifies the write-back: asserts operationIds are null before validation, then checks exact expected values (GENOPID_GET.users, GENOPID_GET.user._id_) after.

Static analysis: Pre-existing broad-exception-catch warnings only (standard Camel exchange.setException(e) pattern). Nothing introduced by this PR.

Reviewed with Claude Code on behalf of @gnodet. This review was generated by an AI agent and may contain inaccuracies; please verify all suggestions before applying.

@github-actions

Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • components/camel-rest-openapi

🔬 Scalpel shadow comparison — Scalpel: 18 tested, 29 compile-only — current: 18 all tested

Maveniverse Scalpel detected 47 affected modules (current approach: 18).

⚠️ Modules only in Scalpel (29)
  • apache-camel
  • camel-allcomponents
  • camel-catalog
  • camel-catalog-console
  • camel-catalog-lucene
  • camel-catalog-maven
  • camel-catalog-suggest
  • camel-componentdsl
  • camel-csimple-maven-plugin
  • 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
  • docs
  • dummy-component

Skip-tests mode would test 18 modules (1 direct + 17 downstream), skip tests for 29 (generated code, meta-modules)

Modules Scalpel would test (18)
  • camel-a2a
  • camel-jbang-mcp
  • camel-jbang-plugin-mcp
  • camel-jbang-plugin-route-parser
  • camel-jbang-plugin-tui
  • camel-jbang-plugin-validate
  • camel-jsonpath
  • camel-knative-http
  • camel-launcher-container
  • camel-micrometer-prometheus
  • camel-oauth
  • camel-observability-services
  • camel-openapi-validator
  • camel-platform-http-main
  • camel-platform-http-vertx
  • camel-rest-openapi
  • camel-yaml-dsl-validator
  • camel-yaml-dsl-validator-maven-plugin
Modules with tests skipped (29)
  • apache-camel
  • camel-allcomponents
  • camel-catalog
  • camel-catalog-console
  • camel-catalog-lucene
  • camel-catalog-maven
  • camel-catalog-suggest
  • camel-componentdsl
  • camel-csimple-maven-plugin
  • 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
  • docs
  • dummy-component

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

All tested modules (47 modules)
  • Camel :: AI :: A2A
  • Camel :: All Components Sync point
  • Camel :: Assembly
  • Camel :: Catalog :: CSimple Maven Plugin (deprecated)
  • Camel :: Catalog :: Camel Catalog
  • Camel :: Catalog :: Camel Report Maven Plugin
  • Camel :: Catalog :: Camel Route Parser
  • Camel :: Catalog :: Console
  • Camel :: Catalog :: Dummy Component
  • Camel :: Catalog :: Lucene (deprecated)
  • Camel :: Catalog :: Maven
  • Camel :: Catalog :: Suggest
  • Camel :: Component DSL
  • Camel :: Coverage
  • Camel :: Docs
  • Camel :: Endpoint DSL
  • Camel :: Endpoint DSL :: Support
  • Camel :: Integration Tests
  • Camel :: JBang :: Core
  • Camel :: JBang :: Integration tests
  • Camel :: JBang :: MCP
  • Camel :: JBang :: Main
  • Camel :: JBang :: Plugin :: Edit
  • Camel :: JBang :: Plugin :: Generate
  • Camel :: JBang :: Plugin :: Kubernetes
  • Camel :: JBang :: Plugin :: MCP
  • Camel :: JBang :: Plugin :: Route Parser
  • Camel :: JBang :: Plugin :: TUI
  • Camel :: JBang :: Plugin :: Testing
  • Camel :: JBang :: Plugin :: Validate
  • Camel :: JSon Path
  • Camel :: Kamelet Main
  • Camel :: Knative HTTP
  • Camel :: Launcher
  • Camel :: Launcher :: Container
  • Camel :: Micrometer :: Prometheus
  • Camel :: OAuth
  • Camel :: Observability Services
  • Camel :: OpenAPI :: Validator
  • Camel :: Platform HTTP :: Main
  • Camel :: Platform HTTP :: Vert.x
  • Camel :: REST OpenApi
  • Camel :: YAML DSL
  • Camel :: YAML DSL :: Deserializers
  • Camel :: YAML DSL :: Maven Plugins
  • Camel :: YAML DSL :: Validator
  • Camel :: YAML DSL :: Validator Maven Plugin

⚙️ View full build and test results

@oscerd oscerd 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. Real dispatch bug: process() routes to direct: + operation.getOperationId(), but validateOpenApi computed the synthetic id only locally and never persisted it, so at runtime getOperationId() returned null → direct:null. Writing op.setOperationId(id) back unifies validation and dispatch. No shared-spec risk — loadSpecificationFrom parses a fresh OpenAPI per consumer, the swagger Operation is a mutable POJO the consumer owns, and the generated id is deterministic/idempotent. Test asserts null-before / generated-id-after.

Reviewed with Claude Code on behalf of Andrea Cosentino. This review was generated by an AI agent and may contain inaccuracies; please verify all suggestions before applying.

@davsclaus davsclaus added this to the 4.22.0 milestone Jul 16, 2026
@davsclaus davsclaus self-assigned this Jul 16, 2026
@davsclaus davsclaus added the bug Something isn't working label Jul 16, 2026
@davsclaus
davsclaus merged commit 63dbd04 into main Jul 16, 2026
5 checks passed
@davsclaus
davsclaus deleted the fix/CAMEL-24115 branch July 16, 2026 13:39
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants