wso2 / product-apim

Welcome to the WSO2 API Manager source code! For info on working with the WSO2 API Manager repository and contributing code, click the link below.
http://wso2.github.io/
Apache License 2.0
848 stars 786 forks source link

Could not save JSON payload when custom mediator in place #12821

Open gbidsilva opened 2 years ago

gbidsilva commented 2 years ago

Description:

I am trying to consume 3rd party API response through WSO2 APIM 3.2 I have an outflow custom mediator in place. Which is doing nothing but just an empty class (source is given below)

public class OutFlowMediatorDummy extends AbstractMediator {
  private static final Log log = LogFactory.getLog(MarketplaceOutFlowMediatorDummy.class);
    @Override
    public boolean mediate(MessageContext messageContext) {
        log.info("Outflow mediator execution ended");
       return true;
    }
}

The endpoint which I used as the service backend is Jira issue api.

Problem: When API is invoked without the outflow mediator in place, I can get the successful response. When API is invoked with outflow mediator in place, an exception is thrown from Synapse (given below)

TID: [] [] [2022-03-25 08:41:54,866] ERROR {org.apache.synapse.transport.passthru.util.DeferredMessageBuilder} - Error building message org.apache.axis2.AxisFault: #Can not parse stream. MessageID: urn:uuid:0680f270-3d32-42c0-9c61-107ef655be0e. Error>>> #getNewJsonPayload. Could not save JSON payload. Invalid input stream found. Payload is not a JSON string.

I also traced the WIRE logs for this respective API call and it seems to be sending the valid JSON response together with correct content type (see below)

TID: [] [] [2022-03-25 08:41:54,855] DEBUG {org.apache.synapse.transport.http.wire} - HTTPS-Sender I/O dispatcher-6 >> "Expect-CT: report-uri="https://web-security-reports.services.atlassian.com/expect-ct-report/global-proxy", enforce, max-age=86400[\r][\n]"

http-outgoing-6: Consume input
>> "HTTP/1.1 200 OK[\r][\n]"
>> "Server: AtlassianProxy/1.19.3.1[\r][\n]"
>> "vary: Accept-Encoding[\r][\n]"
>> "cache-control: no-cache, no-store, no-transform[\r][\n]"
>> "Content-Type: application/json;charset=UTF-8[\r][\n]"
>> "content-encoding: br[\r][\n]"
>> "Strict-Transport-Security: max-age=315360000; includeSubDomains; preload[\r][\n]"
>> "Date: Fri, 25 Mar 2022 03:11:54 GMT[\r][\n]"
>> "ATL-TraceId: 55f44a46bc3e34a3[\r][\n]"
>> "x-arequestid: 208a4cfd-4b6c-49d1-83d4-712fd83fb385[\r][\n]"
>> "x-aaccountid: 611dc54e650a26006e429ef9[\r][\n]"
>> "X-XSS-Protection: 1; mode=block[\r][\n]"
>> "Transfer-Encoding: chunked[\r][\n]"
>> "timing-allow-origin: *[\r][\n]"
>> "x-envoy-upstream-service-time: 356[\r][\n]"
>> "X-Content-Type-Options: nosniff[\r][\n]"
>> "Connection: keep-alive[\r][\n]"
>> "set-cookie: atlassian.xsrf.token=ba43fb73-7930-46cd-84a0-780a0433bbee_7dee8099267779ebfe00c0470f5b1453eeb28a6c_lin; path=/; SameSite=None; Secure[\r][\n]"
TID: [] [] [2022-03-25 08:41:54,855] DEBUG {org.apache.synapse.transport.http.wire} - HTTPS-Sender I/O dispatcher-6 >> "Expect-CT: report-uri="https://web-security-reports.services.atlassian.com/expect-ct-report/global-proxy", enforce, max-age=86400[\r][\n]"
>> "[\r][\n]"
>> "5a4[\r][\n]"
>>

Is this a known but? do we have any workaround to resolve this issue ?

Steps to reproduce:

This only happens for some backend APIs. For other this seems to be working fine.

Affected Product Version:

wso2am-3.2.0.140

Environment details (with versions):

nguni52 commented 1 month ago

@gbidsilva - Has this been resolved? We are running into the same issue.