oscerd opened a new pull request, #25854:
URL: https://github.com/apache/camel/pull/25854

   ## Issue
   [CAMEL-24528](https://issues.apache.org/jira/browse/CAMEL-24528)
   
   ## Problem
   Ten task predictors delegate to a Python inference script and read the 
result via `output.getAsString("data")`.
   Six of them guard the output before using it:
   
   ```java
   String resultJson = output.getAsString("data");
   if (resultJson.contains("\"error\"")) {
       throw new RuntimeCamelException("Python inference failed: " + 
resultJson);
   }
   ```
   
   Four do **not**: `TextGenerationPredictor`, `SummarizationPredictor`, 
`QuestionAnsweringPredictor`
   and `TextToImagePredictor`. When the Python script fails and returns a JSON 
error payload
   (`{"error": ...}`), these four set it as the successful result:
   
   - text generation / summarization / question answering return the raw error 
JSON as the body;
   - text-to-image serves the error JSON bytes to the caller as `image/png`.
   
   ## Fix
   Add the same error guard to the four predictors. For text-to-image (whose 
output is raw image bytes)
   the returned bytes are decoded to a string to check for the error marker 
before the image body is set.
   
   ## Testing
   - New `PredictorErrorHandlingTest` asserts each of the four predictors 
throws on an error payload, and
     that a successful text-generation result is still passed through.
   - `mvn -Psourcecheck validate` green.
   
   _Claude Code on behalf of oscerd_


-- 
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]

Reply via email to