jcabi-github icon indicating copy to clipboard operation
jcabi-github copied to clipboard

Got an exception when trying to get contents

Open lthuangiang opened this issue 10 years ago • 22 comments

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)

lthuangiang avatar Aug 21 '14 18:08 lthuangiang

I'll ask someone to take care of this task soon

dmarkov avatar Aug 24 '14 09:08 dmarkov

this task will get someone's attention soon

dmarkov avatar Aug 27 '14 13:08 dmarkov

@hariso it's yours now, please proceed keeping in mind our principles. Feel free to ask any technical questions right here in the ticket

dmarkov avatar Aug 31 '14 09:08 dmarkov

@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

dmarkov avatar Aug 31 '14 09:08 dmarkov

many thanks for the report, I topped your account for 15 mins, transaction 43893062

dmarkov avatar Aug 31 '14 09:08 dmarkov

@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

dmarkov avatar Sep 07 '14 12:09 dmarkov

@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

dmarkov avatar Sep 18 '14 10:09 dmarkov

@longtimeago it's in your hands now, please proceed

dmarkov avatar Dec 10 '14 10:12 dmarkov

@yegor256 Please, assign someone else. Unfortunately, I've lack of time.

longtimeago avatar Dec 21 '14 10:12 longtimeago

@longtimeago you're holding this task for 11 days already

dmarkov avatar Dec 22 '14 09:12 dmarkov

@dmarkov give it to someone else pls

yegor256 avatar Dec 22 '14 09:12 yegor256

@dmarkov give it to someone else pls

@yegor256 all right, we'll find someone else for this task

dmarkov avatar Dec 25 '14 09:12 dmarkov

@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 avatar Dec 26 '14 09:12 dmarkov

@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

asaen avatar Jan 06 '15 01:01 asaen

@dmarkov please, assign this task to someone else.

asaen avatar Jan 09 '15 19:01 asaen

@dmarkov please, assign this task to someone else.

@darkled I will assign somebody else to this issue

dmarkov avatar Jan 12 '15 11:01 dmarkov

@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 avatar Jan 14 '15 12:01 dmarkov

@dmarkov Waiting for #968 here

palyuga avatar Jan 16 '15 11:01 palyuga

@dmarkov Waiting for #968 here

@palyuga OK, let's wait for #968

dmarkov avatar Jan 19 '15 07:01 dmarkov

@lthuangiang #968 is closed, it was an impediment

dmarkov avatar Oct 16 '15 09:10 dmarkov

@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

dmarkov avatar Nov 02 '15 10:11 dmarkov

@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

dmarkov avatar Nov 05 '15 13:11 dmarkov