plaid-java icon indicating copy to clipboard operation
plaid-java copied to clipboard

Not recieving full error details on requests

Open nissane opened this issue 4 years ago • 13 comments

How do we get error details on an invalid api call? For example, if I provide required data during a request, using the rest api, I get error responses that looks like: { "display_message": null, "documentation_url": "https://plaid.com/docs/?ref=error#invalid-input-errors", "error_code": "INVALID_INSTITUTION", "error_message": "invalid institution_id provided", "error_type": "INVALID_INPUT", "request_id": "hKjwtoomMY7wmKl", "suggested_action": null }

Yet the the Java api does not seem to return details on the error, for example, this is about as much as I get in the response: Response{protocol=http/1.1, code=400, message=Bad Request, url=https://sandbox.plaid.com/sandbox/public_token/create}

Screen Shot 2021-03-21 at 4 15 26 PM

Thank You.

nissane avatar Mar 21 '21 20:03 nissane

@nissane sorry for the delay in responding, but if you expand the content object inside the error body, does it contain this information? that's where i would expect to find it. Also, just to clarify, can you let us know whether you're using the beta or mainline version of the client library? thanks!

phoenixy1 avatar May 11 '21 06:05 phoenixy1

@nissane just wanted to check to see if you got a chance to try out the suggestion above? thanks!

phoenixy1 avatar May 18 '21 23:05 phoenixy1

Yes, i am using version 9.0.0-beta-3. That is the full error body I received.

nissane avatar May 19 '21 20:05 nissane

Can you provide a screenshot of the content object expanded? It appears from your screenshot like this information is present, within the content object, but it is not fully expanded so it's hard to tell.

phoenixy1 avatar Aug 27 '21 00:08 phoenixy1

@phoenixy1 I'm running into the same issue as @nissane and I'm not able to access the full error message. Looking at the value of 'content', you're only able to partially see some of the content of the error message but not the full message (see screenshot below).

I using the Plaid-Java v10.0.0

image

magoodah avatar Feb 17 '22 04:02 magoodah

@nissane can you expand the 'errorbody.content' field and post a screenshot of what that looks like?

@magoodah can you expand the 'content.head.data' field or click "view" (at the right edge of your screen) and post screenshots of what that looks like?

IIRC intellij will perform the bytes -> string conversion for you

vorpus avatar Feb 17 '22 22:02 vorpus

There was nothing else in that field. As you can see the rawResponse message in the image I posted had longer string.

It's been a while, I would have to remember what caused that error and try to replicate. I can give it a try, but the output is exactly as I sent originally.

nissane avatar Feb 17 '22 22:02 nissane

I don't have IntelliJ, but in another JetBrains editor I can click 'view' on the right to view the response as a string: Screen Shot 2022-02-17 at 6 03 39 PM

Alternatively, the byte array can be copied into a "byte to string conversion tool" (many tools can be found on google) to get a readable message.

vorpus avatar Feb 17 '22 23:02 vorpus

Your example is on a successful request. This is happening on an error, where we do not have a body. Calling the API directly gives a more descriptive error message than what appears is being returned from the java api.

The rest api returns: { "display_message": null, "documentation_url": "https://plaid.com/docs/?ref=error#invalid-input-errors", "error_code": "INVALID_INSTITUTION", "error_message": "invalid institution_id provided", "error_type": "INVALID_INPUT", "request_id": "hKjwtoomMY7wmKl", "suggested_action": null }

The Java api returns the screenshot I sent up top. It will show bad request, but does not show exactly what it is a bad request.

nissane avatar Feb 17 '22 23:02 nissane

Thanks for following up; the message from the rest API is present in the java API error as well. It just requires a bit of unwrapping it from the response object. If you look at the 'content' field you can see the beginning of the error response: 111919522-d5006b00-8a60-11eb-8fae-84427851cdd6

If you can inspect that field, I think we can find the same detailed error message.

vorpus avatar Feb 17 '22 23:02 vorpus

Hmm, I am debugging the underlying okhttp response (that's the library plaid is using). I do not see the details of the error message there either.

Can you confirm that you see it when you get an error perhaps?

Screen Shot 2022-02-18 at 10 52 08 AM

nissane avatar Feb 18 '22 15:02 nissane

I can see the error message bytes in the response:

Screen Shot 2022-02-25 at 5 35 23 PM

vorpus avatar Feb 25 '22 22:02 vorpus

Yes I see that same data. What I am not seeing are details on the error like you see when you call the rest api. When you call the rest api, below are the details of the error. This is needed so you can determine what went wrong. Where is that text? I don't see it in the screenshot you posted either.

{ "display_message": null, "documentation_url": "https://plaid.com/docs/?ref=error#invalid-input-errors", "error_code": "INVALID_INSTITUTION", "error_message": "invalid institution_id provided", "error_type": "INVALID_INPUT", "request_id": "hKjwtoomMY7wmKl", "suggested_action": null }

nissane avatar Feb 25 '22 22:02 nissane