davsclaus opened a new pull request, #3316:
URL: https://github.com/apache/camel-kamelets/pull/3316
The last part of #3117. It adds the defaults that waited for #3293, #3283
and #3281. Every Kamelet now declares `spec.dataTypes` for its own side, and
every side without a default says why in a YAML comment. That is what the #3250
validator (the next PR) checks.
## New defaults (behaviour changes)
| Kamelet | Default | Before | Now |
|---|---|---|---|
| `github-commit-source`, `github-event-source` | `out: json` | JSON text as
a stream | JSON text in bytes, `Content-Type: application/json` |
| `github-pullrequest-source`, `github-pullrequest-comment-source`,
`github-tag-source` | `out: json` | JSON text as a String | JSON text in bytes,
`Content-Type: application/json` |
| `mongodb-changes-stream-source` | `out: json` | JSON text as a stream |
JSON text in bytes, `Content-Type: application/json` |
| `ceph-source` | `out: binary` | bytes, no `Content-Type` | bytes,
`Content-Type: application/octet-stream`, as `aws-s3-source` |
| `crypto-decrypt-action` | `out: binary` | a stream,
`application/octet-stream` | the same |
The `Output:` paragraphs say "JSON text in bytes", and the Citrus tests
expect `[B` and the new `Content-Type`. The `ceph-source` test removes the
`Content-Type` before the HTTP call, as the ftp tests do
(citrusframework/citrus#2081).
**Not added:**
- `kafka-batch-source`: the body is a List of Exchanges, and the json data
type fails the batch with `StreamConstraintsException: Document nesting depth
(501) exceeds the maximum allowed (500)` through `DefaultExchange["context"]`.
I tried it with KafkaIT, and the batch tests failed with that error. The reason
is now in a comment.
## A reason on every side without a default
Of the 276 Kamelet sides, 175 have a default. The other 101 each carry a `#
No 'default:' here on purpose: …` comment, and 7 had one already. Where a side
was not declared at all, it is now an empty `headers: {}`. That changes nothing
at runtime: only a `default` runs a transformer.
`KameletsCatalog.getKameletSupportedHeaders` still falls back to the component
headers for an empty block. The reasons fall into a few groups:
- **The body type depends on an option or on the message:**
- `getObject` or `getBlob` on the event-based sources.
- `format` on `data-type-action`, `direction` on the xj actions,
`operation` on `pqc-kem-action`.
- `jsonPayload` (`cassandra-sink`), `encoding` (`fhir-sink`), `binary`
(`azure-servicebus-sink`), `deserializeType` (`salesforce-pubsub-source`).
- The JMS message kind on the JMS Kamelets, the data coding on
`smpp-source`, the content type on `spring-rabbitmq-source`.
- **A default would replace a `Content-Type` that matters**, as the text and
binary data types always set it:
- The service's header is copied onto the message: `http-source`,
`webhook-source`, `nats-source`, `mail-imap-source`,
`ms-exchange-online-imap-oauth-source`, `timer-source`.
- The header chooses how the message is sent: `http-sink`,
`azure-functions-sink`, `mail-sink` (HTML or plain text), `telegram-sink`
(photo or text).
- The header is passed on to the service: SNS and SQS message attributes,
Kafka record headers, NATS headers, Pub/Sub attributes.
- **The Kamelet takes or gives parsed data**, a Map, a List or a JsonNode,
which no data type keeps:
- The field actions. Their output also follows the `Content-Type` header.
- `jolt-transformation-action`, `json-serialize-action`, `jsonata-action`,
`splunk-hec-sink`.
- The Avro and Protobuf serialize actions.
- **The template actions** take any body, including the fields of a Map or a
Java object. They can write any text, such as JSON or XML, so a text output
default would mark all of it `text/plain`.
One is a gap rather than a decision: `couchbase-source` says the json data
type has not been tried with its rows yet.
## Tests
Run against Camel 4.24.0-SNAPSHOT from a local build of main, which includes
CAMEL-27299, CAMEL-27306 and CAMEL-27325:
| Test class | Result |
|---|---|
| CloudIT (github, ceph) | 7/7 |
| MongoIT | 3/3 |
| CommonIT | 70/71 |
| `./mvnw -o clean install -DskipITs` | BUILD SUCCESS |
The one CommonIT failure is `jolt-transformation-action-route-test`. It also
fails without this PR: the test expects the old CAMEL-27306 behaviour (a
JsonNode gives a null body), and the fix now gives a Map. The jolt follow-up of
CAMEL-27306 updates that test.
`KameletsCatalogTest.testGetDataTypes` used `splunk-hec-sink` as a Kamelet
without data types. It now checks the empty `in` side instead.
## Upgrade note (for #3190)
> The `github-commit-source`, `github-event-source`,
`github-pullrequest-source`, `github-pullrequest-comment-source`,
`github-tag-source` and `mongodb-changes-stream-source` Kamelets declare a
default `json` output: the body is JSON text in bytes (it was a String or a
stream) with `Content-Type: application/json`. `ceph-source` declares a default
`binary` output and sets `Content-Type: application/octet-stream`, as
`aws-s3-source` does.
_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]