Decoding errror with content-encoding 'gzip'
See original GitHub issueDescribe the bug
When trying to fetch an organization from public GitHub via getOrganization("...")
the response body cannot be parsed correctly and the method throws an IOException
.
There seems to be an issue with whitespaces in the (assumed) JSON response, indicated by Illegal character ((CTRL-CHAR, code 31))
. Some debugging down to GithubResponse::parseBody
shows that
responseInfo.headerField("content-encoding")
resolves to "gzip"
for some reason.
Here is the full stacktrace:
org.kohsuke.github.HttpException: Server returned HTTP response code: 200, message: 'null' for URL: https://api.github.com/orgs/MovingBlocks
at org.kohsuke.github.GitHubClient.interpretApiError(GitHubClient.java:443) ~[github-api-1.108.jar:na]
at org.kohsuke.github.GitHubClient.sendRequest(GitHubClient.java:366) ~[github-api-1.108.jar:na]
at org.kohsuke.github.GitHubClient.sendRequest(GitHubClient.java:310) ~[github-api-1.108.jar:na]
at org.kohsuke.github.Requester.fetch(Requester.java:71) ~[github-api-1.108.jar:na]
at org.kohsuke.github.GitHub.getOrganization(GitHub.java:489) ~[github-api-1.108.jar:na]
at org.terasology.launcher.updater.LauncherUpdater.updateAvailable(LauncherUpdater.java:91) ~[main/:na]
at org.terasology.launcher.LauncherInitTask.checkForLauncherUpdates(LauncherInitTask.java:181) [main/:na]
at org.terasology.launcher.LauncherInitTask.call(LauncherInitTask.java:81) [main/:na]
at org.terasology.launcher.LauncherInitTask.call(LauncherInitTask.java:44) [main/:na]
at javafx.concurrent.Task$TaskCallable.call(Task.java:1423) [jfxrt.jar:na]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_232]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_232]
Caused by: com.fasterxml.jackson.core.JsonParseException: Illegal character ((CTRL-CHAR, code 31)): only regular white space (\r, \n, \t) is allowed between tokens
at [Source: (String)" ??Mo?0??????n?5?C??????P?b?6??EC.???}?7;e7??C?z_?s?G?y?????]a~?<??Io??:???>?v????{?z??T?^??+?????;"?Q?X9??$E#?G?*?-s?C4G^\e?A?^??D?A?]M????jz????????H^C???????p\|P??gJ???L??V8a.??6?d?L????>?l?[??
??l?=?
?|???L&?pV?D?j,?K??j?v?6??Sc??O?W*?=g?8Y?_??n(?fHL??fBQj!i.F^?#K 4S?P?�?-?p?|??Y?8??????9?T?"??]q??/?
x?J?Yn???v????_????pP???/?(ZD?"???$?$??5??S?????!?Mnn?M????q?6???XP? "; line: 1, column: 2]
at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1840) ~[jackson-core-2.10.2.jar:2.10.2]
at com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:712) ~[jackson-core-2.10.2.jar:2.10.2]
at com.fasterxml.jackson.core.base.ParserMinimalBase._throwInvalidSpace(ParserMinimalBase.java:690) ~[jackson-core-2.10.2.jar:2.10.2]
at com.fasterxml.jackson.core.json.ReaderBasedJsonParser._skipWSOrEnd(ReaderBasedJsonParser.java:2373) ~[jackson-core-2.10.2.jar:2.10.2]
at com.fasterxml.jackson.core.json.ReaderBasedJsonParser.nextToken(ReaderBasedJsonParser.java:672) ~[jackson-core-2.10.2.jar:2.10.2]
at com.fasterxml.jackson.databind.ObjectReader._initForReading(ObjectReader.java:357) ~[jackson-databind-2.10.2.jar:2.10.2]
at com.fasterxml.jackson.databind.ObjectReader._bindAndClose(ObjectReader.java:1704) ~[jackson-databind-2.10.2.jar:2.10.2]
at com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:1261) ~[jackson-databind-2.10.2.jar:2.10.2]
at org.kohsuke.github.GitHubResponse.parseBody(GitHubResponse.java:84) ~[github-api-1.108.jar:na]
at org.kohsuke.github.Requester.lambda$fetch$1(Requester.java:71) ~[github-api-1.108.jar:na]
at org.kohsuke.github.GitHubClient.createResponse(GitHubClient.java:404) ~[github-api-1.108.jar:na]
at org.kohsuke.github.GitHubClient.sendRequest(GitHubClient.java:358) ~[github-api-1.108.jar:na]
... 10 common frames omitted
To Reproduce
This is the MWE from my code to reproduce this error.
try {
Github github = GitHub.connectAnonymously();
GHOrganization movingBlocks = github.getOrganization("MovingBlocks");
} catch (IOException e) {
e.printStacktrace();
}
Expected behavior
I expect that a response with 200 OK is parsed correctly and does not throw an IOException.
Alternatively, is there a way to set custom headers, e.g., setting “accept-encoding” to ensure the lib can parse the response body?
Desktop (please complete the following information):
- OS: macOS / Windows 10
- Java: 1.8.0_232 BellSoft
- Version 1.108
Issue Analytics
- State:
- Created 4 years ago
- Comments:13 (6 by maintainers)
Top GitHub Comments
Switching the implementation of
GitHubResponse.headerField()
to this seems to fix the problem:I’ll raise a PR, but I’m struggling to create a test case at the moment because (the ironies) I can’t persuade WireMock not to capitalise the
content-encoding
header name.OK, found the problem:
headerField
is case-sensitive and GitHub have changed their response headers to be all lower case.