camel-docling: honor the operationId URI path segment to select the operation - #26102
camel-docling: honor the operationId URI path segment to select the operation#26102Croway wants to merge 1 commit into
Conversation
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
…peration DoclingEndpoint stores the docling:<operationId> URI path segment (e.g. docling:EXTRACT_STRUCTURED_DATA) but DoclingComponent never applied it to DoclingConfiguration.operation, and DoclingProducer.getOperation() only consults the CamelDoclingOperation header or the configured/default operation (CONVERT_TO_MARKDOWN). As a result, an endpoint like docling:EXTRACT_STRUCTURED_DATA?useDoclingServe=true&outputFormat=json silently performed CONVERT_TO_MARKDOWN instead, since the operation was never set anywhere else - the path segment was purely cosmetic despite the component's own syntax being documented as "docling:operationId". DoclingComponent.createEndpoint() now parses the operationId into a DoclingOperations value and applies it to the endpoint's configuration before setProperties() runs, so an explicit ?operation=... query parameter (as already used in this component's own tests and docs) still takes precedence, and an operationId that isn't a recognized operation name is silently ignored rather than failing endpoint creation. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Hs6c6LpuL8ZZ3gaSXwt7CS
3174341 to
f462af9
Compare
|
🧪 CI tested the following changed modules:
🔬 Scalpel shadow comparison — Scalpel: 9 tested, 27 compile-only — current: 9 all testedMaveniverse Scalpel detected 36 affected modules (current approach: 9).
|
gnodet
left a comment
There was a problem hiding this comment.
Solid bugfix. The operationId-to-operation wiring is correctly placed before setProperties(), preserving the right precedence chain: header > ?operation= param > operationId path segment > default. The silent IllegalArgumentException catch is the correct choice — failing on unrecognized operationId values would break existing endpoints like docling:convert and docling:process. Test coverage hits the key cases: operationId selecting operation, explicit param overriding a recognized operationId, and pre-existing tests already cover unrecognized operationId with explicit params.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
Summary
DoclingEndpointstores thedocling:<operationId>URI path segment (e.g.docling:EXTRACT_STRUCTURED_DATA, matching the component's own documented syntaxdocling:operationId), butDoclingComponentnever applied it toDoclingConfiguration.operation, andDoclingProducer.getOperation()only consults theCamelDoclingOperationheader or the configured/default operation (CONVERT_TO_MARKDOWN).As a result, an endpoint such as:
silently performs
CONVERT_TO_MARKDOWNinstead - the URI path segment is effectively ignored unless the operation is also passed via theoperationquery parameter or theCamelDoclingOperationheader (the pattern already used by this component's own docs/tests, e.g.docling:convert?operation=CONVERT_TO_MARKDOWN).I hit this concretely while testing the
doclingexample in camel-spring-boot-examples: adocument-metadata-extractorroute usingdocling:EXTRACT_STRUCTURED_DATA?...&outputFormat=jsonwas writing markdown text into.jsonfiles (invalid JSON), because it was actually always runningCONVERT_TO_MARKDOWN.DoclingComponent.createEndpoint()now parsesoperationIdinto aDoclingOperationsvalue and applies it to the endpoint's configuration beforesetProperties()runs, so an explicit?operation=...query parameter still takes precedence, and anoperationIdthat isn't a recognized operation name (used as a purely descriptive endpoint id) is silently ignored rather than failing endpoint creation.DoclingComponentTest:operationIdselecting the operation, and an explicitoperationparameter overriding a recognizedoperationId. (The "unrecognized operationId + explicit operation parameter" case was already covered by the existingtestCreateEndpointWithParameters.)Related, not fixed here: once the operation is dispatched correctly,
EXTRACT_STRUCTURED_DATA(andCONVERT_TO_JSONin docling-serve mode) sets the exchange body to aDoclingDocumentPOJO regardless ofoutputFormat, and there's no registered type converter toString/bytes for it - callers need to marshal it explicitly (e.g. viacamel-jackson) before handing it to a byte-oriented endpoint likefile:. Happy to file that as a separate follow-up if useful.Test plan
mvn -o test -Dtest='!*IT'incomponents/camel-ai/camel-docling- all unit tests pass, including the new regression testsdocling-servecontainer via thecamel-spring-boot-examplesdocling example: before the fix,EXTRACT_STRUCTURED_DATAsilently ranCONVERT_TO_MARKDOWN; after the fix, it correctly dispatches to structured-data extractiondocling:convert?operation=...style (used elsewhere in this component's tests/docs) is unaffected