Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jackson cannot deserialize error payload when HTTP status code is 401 #83

Open
at9pm opened this issue Mar 30, 2024 · 2 comments
Open

Comments

@at9pm
Copy link

at9pm commented Mar 30, 2024

I was running locally in JDK21 with environment Xcode / LocalTesting. When I try to getTransactionHistory, if there is abnormal HTTP status code, jackson cannot deserialize it to ErrorPayload.class. 404 can deserialize, but 401 cannot. It should be due to HTTP 401 has an empty response body.

com.apple.itunes.storekit.client.APIException: Failed to call API with httpStatusCode=401
	at com.apple.itunes.storekit.client.AppStoreServerAPIClient.makeHttpCall(AppStoreServerAPIClient.java:132) ~[app-store-server-library-1.1.0.jar:na]
	at com.apple.itunes.storekit.client.AppStoreServerAPIClient.getTransactionHistory(AppStoreServerAPIClient.java:287) ~[app-store-server-library-1.1.0.jar:na]
.
.
.
Caused by: com.fasterxml.jackson.databind.exc.MismatchedInputException: No content to map due to end-of-input
 at [Source: (okhttp3.ResponseBody$BomAwareReader); line: 1, column: 0]
	at com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:59) ~[jackson-databind-2.15.3.jar:2.15.3]
	at com.fasterxml.jackson.databind.ObjectMapper._initForReading(ObjectMapper.java:4916) ~[jackson-databind-2.15.3.jar:2.15.3]
	at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4818) ~[jackson-databind-2.15.3.jar:2.15.3]
	at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3785) ~[jackson-databind-2.15.3.jar:2.15.3]
	at com.apple.itunes.storekit.client.AppStoreServerAPIClient.makeHttpCall(AppStoreServerAPIClient.java:126) ~[app-store-server-library-1.1.0.jar:na]
@alexanderjordanbaker
Copy link
Collaborator

Yes, 401 may have an empty response body, in which case you get a status code of 401 without a body

@at9pm
Copy link
Author

at9pm commented Apr 1, 2024

Perhaps it can be a low priority task to enhance the error handling. Although it is 401, it should not induce a deserialization error. I was a little bit confused at first before I figured out I requested to a wrong enviroment, thus 401.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants