jcabi-github
jcabi-github copied to clipboard
Got an exception when trying to get contents
Following Contents.get()
method, we got an exception
final Repos repos = github().repos();
final Repo repo = repos.get(new Coordinates.Simple("jcabi/jcabi-github"));
System.out.println(new Content.Smart(repo.contents().get("src/main/java/com/jcabi/github/Users.java")).url());
// #output https://api.github.com/repos/jcabi/jcabi-github/contents/src/main/java/com/jcabi/github/Users.java?ref=master
System.out.println(new Content.Smart(repo.contents().get("src/main/java/com/jcabi/github/mock")).url());
ERROR LOG
https://api.github.com/repos/jcabi/jcabi-github/contents/src/main/java/com/jcabi/github/Users.java?ref=master
[[0;37mINFO[m] main com.jcabi.http.request.BaseRequest: #fetch(GET api.github.com /repos/jcabi/jcabi-github/contents/src/main/java/com/jcabi/github/mock): [200 OK] in 2s
javax.json.JsonException: Cannot read JSON object, found JSON array
at org.glassfish.json.JsonReaderImpl.readObject(JsonReaderImpl.java:105)
at com.jcabi.http.response.JsonResponse$VerboseReader.readObject(JsonResponse.java:159)
at com.jcabi.github.RtContents.content(RtContents.java:266)
I'll ask someone to take care of this task soon
this task will get someone's attention soon
@hariso it's yours now, please proceed keeping in mind our principles. Feel free to ask any technical questions right here in the ticket
@hariso The cost of this task is 30 mins (this is exactly how much will be paid, not less not more), when the task is done
many thanks for the report, I topped your account for 15 mins, transaction 43893062
@hariso the task is your hands for the last 10 days.. keep in mind that if it's not closed in the next 48 hours, it will be re-assigned to someone else, see No Obligations principle
@hariso this task is taking too long, I have to change the performer, sorry. Please stop working with it right now. See our no obligations principle
@longtimeago it's in your hands now, please proceed
@yegor256 Please, assign someone else. Unfortunately, I've lack of time.
@longtimeago you're holding this task for 11 days already
@dmarkov give it to someone else pls
@dmarkov give it to someone else pls
@yegor256 all right, we'll find someone else for this task
@darkled this ticket is yours now, please proceed, and keep in mind this. Any technical questions you should ask right here
Budget here is 30 mins (keep this principle in mind)
@dmarkov unfortunately, for the moment jcabi-github
absolutely doesn't support processing of JsonArray
's.
The possible fix of this problem could be this snippet in RtContents
(I can push it if it could make sense):
private Content content(final String path, final String ref)
throws IOException {
final String name = "ref";
final JsonStructure jsonStructure =
this.request.method(Request.GET).uri().path(path)
.queryParam(name, ref).back().fetch().as(RestResponse.class)
.assertStatus(HttpURLConnection.HTTP_OK).as(JsonResponse.class)
.json().read();
String contentPath = null;
if (ValueType.ARRAY == jsonStructure.getValueType()) {
contentPath = path;
} else if (ValueType.OBJECT == jsonStructure.getValueType()) {
contentPath = ((JsonObject) jsonStructure).getString("path");
}
return new RtContent(this.entry.uri().queryParam(name, ref).back(),
this.owner, contentPath);
}
But actually it leads for further problems because somewhere inside this method com.jcabi.github.RtContent.json()
is invoked which has 170 usages in sources and will throw the same exception javax.json.JsonException: Cannot read JSON object, found JSON array
.
So, it looks not possible to fix without the great refactoring of all those classes and I have no idea what to do with it within this issue.
UPD: created a new issue #968 for this problem
@dmarkov please, assign this task to someone else.
@dmarkov please, assign this task to someone else.
@darkled I will assign somebody else to this issue
@palyuga This task is yours, please go ahead keeping in mind this. If any questions, don't hesitate to ask right here... Task's budget is 30 mins (see this for explanation)
@dmarkov Waiting for #968 here
@dmarkov Waiting for #968 here
@palyuga OK, let's wait for #968
@lthuangiang #968 is closed, it was an impediment
@palyuga check this "no obligations principle".. This task is on your name for at least 17 days. If you can't close it within the next 48 hours I will have to assign someone else to it. This article should help if you're stuck... -30 added to your rating, current score is: -30
@palyuga you've been working with this task for too long. I'm sorry, but I'll assign someone else. Please stop working with it. See our no obligations principle. -60 to your rating, your total score is -90