davsclaus opened a new pull request, #3303:
URL: https://github.com/apache/camel-kamelets/pull/3303
Batch 7 (core and AI documents) of #3117: a `text` default data type on the
`out` side of `counter-source`, `cron-source`, `docling-convert-action` and
`tika-extract-text-action`. Camel runs the transformer of a default data type
on every message, so each default changes the body class or the `Content-Type`.
The table shows what changes. It was checked with `camel run` (before and
after) and with the Citrus tests, on a local Camel main build that has
CAMEL-27258.
> **Draft:** the `counter-source` and `cron-source` tests check the body
class and `Content-Type` in the consuming route. That needs CAMEL-27258, which
applies a source's output type when the message is handed to the consuming
route. The fix was merged today, after the published Camel 4.24.0-SNAPSHOT that
CI uses was built, so this PR waits for a newer snapshot. The Docling and Tika
tests do not depend on it: an action's output type was already applied when the
action completes.
## What changes
| Kamelet | out | What changes (before → after) |
|---|---|---|
| `counter-source` | `text` | `Integer` → `String` (the same number, as
text). `Content-Type` stays `text/plain`. |
| `cron-source` | `text` (D1) | `String` as before. No `Content-Type` →
`text/plain`, also when the `message` option is JSON or XML. |
| `docling-convert-action` | `text` | `String` as before. The incoming
`Content-Type` was kept (for example `application/pdf` on the Markdown) →
`text/plain`, also for `CONVERT_TO_HTML`. |
| `tika-extract-text-action` | `text` | `String` as before. No
`Content-Type` (the template removes the incoming one) → `text/plain`, also for
`outputFormat` `html` and `xml`. |
The `Output:` paragraphs of these Kamelets now say this.
Not done, as the proposal says:
- No `in` default on `docling-convert-action` and
`tika-extract-text-action`: `binary` would read a file or a plain stream into
memory before their `maxDocumentSize` check. I checked that the check still
fails an oversized document before the parse.
- `timer-source` keeps no default: its `contentType` option sets the
`Content-Type`, which `text` would replace. `counter-source` and `cron-source`
have no such option.
## Tests
- `camel run`, before and after, with probe routes: `counter-source`,
`cron-source` (with a JSON `message`), `tika-extract-text-action` (text,
`html`, bytes with `maxDocumentSize`, a document over `maxDocumentSize`),
`docling-convert-action` against an in-process Docling Serve stub (Markdown,
`CONVERT_TO_HTML`, bytes with `maxDocumentSize`).
- The counter, cron, docling and tika Citrus routes did not record the body.
They now record the body class and `Content-Type`: the counter and cron routes
log them and the tests verify that line; the docling and tika routes send them
as `X-Body-Type`/`X-Content-Type` with their report, and the tests check them.
- `CommonIT#counter+cron+langchain4jIngest`: 13 tests pass, run locally with
Camel main + CAMEL-27258 in `~/.m2`. Run against the old Docling and Tika
Kamelets, their two tests fail on `X-Content-Type` (`ct=` instead of
`ct=text/plain`), so the checks catch the change.
- `./mvnw clean install` from the root passes, run twice.
## Overlap with open PRs
- **#3287** adds the `verified` label to `docling-convert-action`, in
another part of the file, so there is no conflict.
- **#3294** (descriptions) does not touch these Kamelets.
## Upgrade note for #3190
```markdown
- **Default data types on the counter, cron, Docling and Tika Kamelets
(#PR_NUMBER):**
- `counter-source` (`out: text`) gives the number as a `String` instead of
an `Integer`. Where a number is needed, convert it, for example with
`convertBodyTo` to `java.lang.Integer`.
- `cron-source` (`out: text`) sets `Content-Type: text/plain`, also when
the `message` option is JSON or XML. Set the header after the source when
another type is needed.
- `docling-convert-action` (`out: text`) sets `Content-Type: text/plain`
on the converted document, also for `CONVERT_TO_HTML`. Before, the incoming
`Content-Type`, such as `application/pdf`, was kept.
- `tika-extract-text-action` (`out: text`) sets `Content-Type: text/plain`
on the text, also for `outputFormat` `html` and `xml`. Before, it set none.
```
_Claude Code on behalf of Claus Ibsen_
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_016Y4dDmBDsSWV117kccuNf9
--
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]