Claus Ibsen created CAMEL-26211:
-----------------------------------
Summary: camel-djl - a cv or audio body without a converter
reaches the predictor as null, and nlp predictors reject bytes and streams
Key: CAMEL-26211
URL: https://issues.apache.org/jira/browse/CAMEL-26211
Project: Camel
Issue Type: Bug
Components: camel-ai
Reporter: Claus Ibsen
Fix For: 4.24.0
Found while adding the catalog body types of djl (CAMEL-24961, PR #28401).
h4. 1. A cv or audio body without a converter reaches the predictor as null
{{AbstractCvZooPredictor.process}} (main 2a465aa4814c, line 41) and
{{CustomCvPredictor}} (line 49), and the same code in {{ZooAudioPredictor}} and
{{CustomAudioPredictor}}, read the body with {{getBody(Image.class)}} /
{{getBody(Audio.class)}} and catch {{TypeConversionException}}. For a String,
Map, {{BufferedImage}} or null body there is no converter, {{getBody}} returns
null and the predictor fails with "Could not process input or output" instead
of "Data type is not supported". Checked on 4.24.0-SNAPSHOT with the zoo mlp
image classification model.
Proposed: use {{getMandatoryBody}} (or check for null) so the "Data type is not
supported" message is given.
h4. 2. nlp predictors accept only a String body
{{AbstractNlpZooPredictor}} (line 38) and {{CustomNlpPredictor}} (line 42)
check {{getBody() instanceof String}}, so a {{byte[]}} or {{InputStream}} text
body (from file, HTTP or JMS) fails with "Data type is not supported. Body
should be String". Checked on 4.24.0-SNAPSHOT with the zoo distilbert sentiment
model.
Proposed: convert the body with {{getMandatoryBody(String.class)}}.
h4. 3. Custom predictors look up the model and translator per message
{{CustomCvPredictor.predict}} (lines 59-62) and the other {{Custom*Predictor}}
classes look up {{model}} and {{translator}} in the registry for every message;
a wrong name gives a {{NullPointerException}} at the first message instead of
an error at startup. Read in the code, not run.
Proposed: look them up once when the producer starts and fail there with the
missing bean name.
_Claude Code on behalf of davsclaus_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)