Saravanakumar Selvaraj created CAMEL-27755:
----------------------------------------------

             Summary: camel-alibaba-fc: the exchange completes for a failed 
function with the status 200, and no Camel header shows the error
                 Key: CAMEL-27755
                 URL: https://issues.apache.org/jira/browse/CAMEL-27755
             Project: Camel
          Issue Type: Bug
    Affects Versions: 4.23.0
            Reporter: Saravanakumar Selvaraj


Function Compute can answer InvokeFunction for a failed function with the 
status 200 and the response header X-Fc-Error-Type. The OpenAPI metadata of 
FC-Open 2021-04-06 lists this header for the 200 response of InvokeFunction. 
Its values are HandledInvocationError and UnhandledInvocationError. The 
metadata is at 
https://api.alibabacloud.com/meta/v1/products/FC-Open/versions/2021-04-06/api-docs.json

I checked the code of main at e785ba78ad52, fc_open20210406 2.1.0, tea-openapi 
0.3.20, tea-util 0.2.28, tea 1.4.3 and OkHttp 4.12.0:

- For a response, tea-openapi throws a TeaException only for a status from 400 
to 599. For any other status, it returns the body, the headers and the status 
code.
- FCProducer.invokeFunction puts the status code, the headers and the body of 
the response into a Map body. It sets the headers CamelAlibabaFcStatusCode and 
CamelAlibabaFcRequestId. No code of the component reads X-Fc-Error-Type.
- So the exchange completes for a failed function, with 
CamelAlibabaFcStatusCode 200. onException and the error handler do not run.
- The producer keeps X-Fc-Error-Type only as the key x-fc-error-type in the 
headers Map of the body. tea copies the headers from Headers.toMultimap of 
OkHttp, which writes the names in lower case.
- No text of the component speaks of a failed function. The body type text says 
that the body key of the Map holds the payload that the function returns.

Proposed change:

- A header with the value of X-Fc-Error-Type, as camel-aws2-lambda sets 
CamelAwsLambdaFunctionError.
- A sentence in the header text and on the doc page on how a route detects a 
failed function.

Whether a failed function fails the exchange is a decision for the review.

_Claude Code on behalf of saravanakumar1987_




--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to