Fix docling example metadata extraction writing invalid JSON - #196
Open
Croway wants to merge 1 commit into
Open
Conversation
The document-metadata-extractor route used docling:EXTRACT_STRUCTURED_DATA as the endpoint URI path, but camel-docling only dispatches on the "operation" query parameter (or the CamelDoclingOperation header) - the URI path segment is descriptive only. Without it, the endpoint silently fell back to its CONVERT_TO_MARKDOWN default, so the "metadata" route was actually just converting to markdown and writing it into a .json file. Also add the missing operation query parameter, and marshal the DoclingDocument result to JSON explicitly (EXTRACT_STRUCTURED_DATA returns a structured object, not JSON text, and camel-docling has no built-in type converter for it), via camel-jackson. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Hs6c6LpuL8ZZ3gaSXwt7CS
Croway
force-pushed
the
fix-docling-metadata-extraction-json
branch
from
September 3, 2026 17:32
9bc5b04 to
211aba7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
document-metadata-extractorroute useddocling:EXTRACT_STRUCTURED_DATAas the endpoint, butcamel-doclingonly dispatches on theoperationquery parameter (or theCamelDoclingOperationheader) - the URI path segment is descriptive only. Without an explicitoperation=...parameter, the endpoint silently fell back to itsCONVERT_TO_MARKDOWNdefault, so the "metadata" route was actually just converting to markdown and writing it into a.jsonfile (invalid JSON).operation=CONVERT_TO_MARKDOWN/operation=EXTRACT_STRUCTURED_DATAquery parameter. The URI path segment itself was renamed to a lowercase, hyphenated label (docling:convert-to-markdown,docling:extract-structured-data) instead of repeating the operation name, to make clear it's just an endpoint id and theoperationparameter is what actually selects the behavior.EXTRACT_STRUCTURED_DATAreturns aDoclingDocumentobject, not JSON text (theoutputFormatparameter isn't read by that operation, and there's no type converter for the object), so the route now marshals it to JSON viacamel-jacksonbefore writing it to file.I've also filed the root cause against
camel-doclingitself: apache/camel#26102 (thedocling:<operationId>URI path segment not being honored). This PR fixes the example regardless of when/whether that lands, since the explicitoperation=...parameter and the JSON marshalling step are both needed either way.Test plan
docling-servecontainer (docker run -p 5001:5001 ghcr.io/docling-project/docling-serve:latest)output/metadata/*.jsoncontained markdown text, invalid JSONoutput/metadata/*.jsoncontains valid, well-formed JSON (DoclingDocumentschema)document-to-markdown-converterroute still produces correct markdown outputmvn clean packagesucceeds🤖 Generated with Claude Code
https://claude.ai/code/session_01Hs6c6LpuL8ZZ3gaSXwt7CS