Saravanakumar Selvaraj created CAMEL-27759:
----------------------------------------------
Summary: camel-alibaba-kms, camel-alibaba-fc,
camel-alibaba-eventbridge: some texts on the message body do not match the code
Key: CAMEL-27759
URL: https://issues.apache.org/jira/browse/CAMEL-27759
Project: Camel
Issue Type: Bug
Affects Versions: 4.23.0
Reporter: Saravanakumar Selvaraj
I checked the body types, the doc pages and the producers on main at
e785ba78ad52. I also read the type converters of Camel core that the producers
use. The texts of camel-alibaba-sms on the body match the code.
camel-alibaba-kms:
- The section "Plaintext of encrypt" of the doc page gives one set of rules for
the body and the header. The rules differ in two ways.
- For the body, a byte[], an InputStream or a file keeps its bytes. For the
CamelAlibabaKmsPlaintext header, the producer reads these as text in the
charset of the exchange, so binary data changes.
- The page says that the producer encrypts a UUID, a URI or a java.time value
as its text. That holds for the header and the exchange property only. In the
body, these values fail with an InvalidPayloadException, as no converter gives
their bytes. Even in the header, a ZoneId or a MonthDay fails, as neither is a
Temporal nor a TemporalAmount.
- The body type of decrypt lists text only. KMSProducer.decrypt reads the body
with getBody(String.class), so a byte[], a stream and a file work too. A Map or
a POJO that Camel reads only as its toString() goes to KMS as that text.
- The CamelAlibabaKmsPlaintext header text says that a Map or a POJO fails, as
it does in the message body. KMSUtils.createClientConfigurations checks the
header for every operation, so such a value also fails decrypt and
generateDataKey. Neither operation uses the plaintext. In the body, the
producer rejects a Map for encrypt only. CAMEL-27035 made a non-numeric
numberOfBytes header fail generateDataKey alone, the only operation that sends
it.
- The byOption carriers of encrypt and decrypt do not change when a step sets
the plaintext or ciphertextBlob option. The producer then does not read the
body. camel-yaml-dsl-validator can then report an error for such a step after
another kms step, which leaves a Map.
camel-alibaba-kms and camel-alibaba-fc:
- The texts and doc pages say that a Map or a POJO fails, as it does not
convert to bytes. A camel-util-json JsonObject is a Map that does convert.
camel-support has a converter to the bytes of its JSON text. So invokeFunction
sends it, and encrypt encrypts it, in the charset of the exchange. A JsonObject
with a value that Jsoner cannot write, such as a UUID, still fails. The entries
of CAMEL-26257 and CAMEL-26258 in the 4.24 upgrade guide make the same claim.
camel-alibaba-fc:
- The producerOut text names the CamelAlibabaFcStatusCode header for
invokeFunction only. FCProducer.getFunction sets it too, and the body of
getFunction has no status code.
camel-alibaba-eventbridge:
- The body type text says that another POJO fails. A POJO that converts to
bytes, such as a ByteBuffer, does not fail. The same holds for a Jackson
JsonNode with camel-jackson on the classpath. The producer publishes its bytes
as the JSON data of the event.
- The text says that a Map or a POJO as the data of a Map body becomes JSON.
MapCloudEventValidator does so with Gson, which has no adapter for a Jackson
JsonNode. With gson 2.15.0 and jackson-databind 2.23.0, I ran new Gson().toJson
on the JsonNode of the first line below. It gave the second line:
{noformat}
{"orderId":"123"}
{"_children":{"orderId":{"_value":"123"}},"_nodeFactory":{"_cfgBigDecimalExact":false}}
{noformat}
_Claude Code on behalf of saravanakumar1987_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)