davsclaus opened a new pull request, #30675: URL: https://github.com/apache/camel/pull/30675
_Claude Code on behalf of Claus Ibsen (davsclaus)_ [CAMEL-27468](https://issues.apache.org/jira/browse/CAMEL-27468) The TUI and `camel cmd route-structure` show the Java types each step has been reached with (CAMEL-25892), but a `byte[]` or a stream can hold JSON, XML, CSV or a PDF. This PR also records the format of the payload, from the `Content-Type` header each step is reached with, and shows it next to the type: `byte[] · json`. ### Runtime (core) - `BodyTypeRegistry` (new in 4.24, unreleased) gets `addBodyFormat` / `getBodyFormats`; `DefaultBodyTypeRegistry` keeps the distinct formats per node, in the order first seen, at most 8 per node. - `DefaultMessageHistory.captureBody` reads `Content-Type` and records its format, only while the message history is on (as before). - `BodyFacts.formatOf` maps the media type to the format names of the catalog (`BodyType.format`, the Kamelet data types): - `application/json` and `+json` -> `json` - `application/xml`, `text/xml` and `+xml` -> `xml` - `text/csv` -> `csv` - `application/yaml` (and `x-yaml`, `+yaml`) -> `yaml` - other `text/*` -> `text` - `application/octet-stream` -> `binary` - anything else as it is, without its parameters, in lower case - **Only a payload has a format** (text, bytes, a stream or a file). A `Content-Type` left on a `LinkedHashMap` after an unmarshal is about the payload the Map was made from, so `LinkedHashMap · json` would hide exactly the mismatch the ticket wants to spot (a Map going into a sink that takes `json`). A Map stays `LinkedHashMap`. - A message without `Content-Type` adds no format. The ticket said "(or none)", but I did not record "none": a step reached with json by some messages and with no `Content-Type` by others shows `json`. - The value comes from the message, so it is only kept when it looks like a media type (RFC 6838 characters, one `/`, at most 64 characters). A `Content-Type` longer than 256 characters is not parsed. A crafted header cannot put control characters into the TUI. ### Consoles, CLI, MCP - `body-type`, `route-structure` and `processor` (also `route` with processors) dev consoles have `bodyFormats` (left out when there is none). Their text output reads `body: byte[] · json`. - `varied` (console option, `camel cmd route-structure --varied`, the AI tool and the MCP tool) also keeps a step reached with more than one format. - `camel cmd route-structure` prints the formats after the types. The descriptions of the AI tool and the `camel_runtime_route_structure` MCP tool name `bodyFormats`, so an assistant can compare it with the format the catalog says a step takes. ### TUI and diagrams - The Source, Routes and Diagram views show `byte[] · json`. A step reached with more than one format (`⚠ String · xml | csv`) is marked as a step with more than one kind is: the gutter mark, the warning colour, and the mark on the diagram box. - When there is not enough room, the formats are dropped before the types are. - The Info panel of the diagram lists `Format: json`, or `Formats: …` with a warning when there is more than one. The quick documentation of a source line says the same. - camel-diagram (`NodeInfo.bodyFormats`, the PNG route diagram labels) gets the same, since the TUI diagram goes through it. ### Docs - Message History EIP page: a new section, "The format of the payload". - CLI diagnostics, MCP, TUI source editor and TUI diagram pages, and the TUI help. - Regenerated: the dev-console JSONs and OpenAPI, the command metadata, and the catalog doc mirror. ### Tests - core: `BodyFactsTest` (the mapping, and values that are not media types), `DefaultBodyTypeRegistryTest` (distinct, bounded), `BodyTypeRegistryTest` (end to end through routes: formats per step, none for data), `BodyTypeDevConsoleTest` (JSON, text, `varied`). - `CamelRouteStructureActionTest`, `RouteDiagramBodyTypesTest`, `RouteDiagramHelperTest`, and the TUI `BodyTypesViewsTest`, `SourceBodyTypesTest`, `DiagramTopologyTest`. - I ran the affected modules' tests locally, all green: camel-console, the camel-core body-type tests, camel-diagram, the jbang-core route-structure and tool registry tests, the TUI body type, diagram and routes tests including `SourceSizeTest`, and the MCP runtime tools tests. - I did not try the Kamelet demo route (`file-watch-source -> csv-deserialize-action -> split -> postgresql-sink`) live. 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
