naver/cover-checker

Parse exception converting JSON to object

GabrielBB opened this issue · 2 comments

 java -jar cover-checker-console-1.4.0-jar-with-dependencies.jar \
    --cover /api/target/site/jacoco/jacoco.xml \
    --github-token ${token} \
    --repo GabrielBB/** \
    --threshold 80 \
    --github-url github.com \
    --pr 1 \
    -type jacoco
Exception in thread "main" java.lang.IllegalStateException: java.io.IOException: Parse exception converting JSON to object
        at com.naver.nid.cover.github.manager.GithubPullRequestManager.<init>(GithubPullRequestManager.java:52)
        at com.naver.nid.cover.github.manager.GithubPullRequestManager.<init>(GithubPullRequestManager.java:38)
        at com.naver.nid.cover.util.ObjectFactory.getPrManager(ObjectFactory.java:71)
        at com.naver.nid.cover.util.ObjectFactory.getDiffReader(ObjectFactory.java:46)
        at com.naver.nid.cover.Launcher.main(Launcher.java:15)
Caused by: java.io.IOException: Parse exception converting JSON to object
        at org.eclipse.egit.github.core.client.GitHubClient.parseJson(GitHubClient.java:478)
        at org.eclipse.egit.github.core.client.GitHubClient.parseJson(GitHubClient.java:457)
        at org.eclipse.egit.github.core.client.GitHubClient.parseError(GitHubClient.java:568)
        at org.eclipse.egit.github.core.client.GitHubClient.createException(GitHubClient.java:601)
        at org.eclipse.egit.github.core.client.GitHubClient.get(GitHubClient.java:799)
        at org.eclipse.egit.github.core.service.PullRequestService.getPullRequest(PullRequestService.java:115)
        at com.naver.nid.cover.github.manager.GithubPullRequestManager.<init>(GithubPullRequestManager.java:50)
        ... 4 more
Caused by: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:226)
        at com.google.gson.Gson.fromJson(Gson.java:927)
        at com.google.gson.Gson.fromJson(Gson.java:892)
        at org.eclipse.egit.github.core.client.GitHubClient.parseJson(GitHubClient.java:476)
        ... 10 more
Caused by: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $
        at com.google.gson.stream.JsonReader.beginObject(JsonReader.java:385)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:215)
        ... 13 more

Hi, Thank you for your report.

It looks likes wrong --github-url on arguments.
Would you try as below?

 java -jar cover-checker-console-1.4.0-jar-with-dependencies.jar \
    --cover /api/target/site/jacoco/jacoco.xml \
    --github-token ${token} \
    --repo GabrielBB/** \
    --threshold 80 \
    --github-url api.github.com \
    --pr 1 \
    -type jacoco

Also you can drop --github-url argument.
Because api.github.com is the default value of --github-url.

Working good! You did an amazing job. Thank you for this