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

"JsonSyntaxException when parsing 'licenses' array: Expected BEGIN_OBJECT but found STRING" #208

Closed
kyudori opened this issue Sep 8, 2023 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@kyudori
Copy link
Contributor

kyudori commented Sep 8, 2023

Describe the bug
LPVS is running well, but no comment is created when PR is generated.

To Reproduce

  1. Build LPVS Application with Maven and Run it
    mvn clean install
    cd target/
    java -jar lpvs-*.jar
  2. Add Webhooks
  3. Make Pull Request

Error logs

root@KyudoriGram:/mnt/c/users/khh53/desktop/LPVS/LPVS_login/target# java -jar lpvs-1.1.0.jar

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::               (v2.7.15)

2023-09-08 23:56:08.913  INFO 1522 --- [           main] com.lpvs.LicensePreValidationSystem      : Starting LicensePreValidationSystem v1.1.0 using Java 11.0.19 on KyudoriGram with PID 1522 (/mnt/c/users/khh53/desktop/LPVS/LPVS_login/target/lpvs-1.1.0.jar started by root in /mnt/c/users/khh53/desktop/LPVS/LPVS_login/target)
2023-09-08 23:56:08.938  INFO 1522 --- [           main] com.lpvs.LicensePreValidationSystem      : No active profile set, falling back to 1 default profile: "default"
2023-09-08 23:56:12.601  INFO 1522 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2023-09-08 23:56:12.925  INFO 1522 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 270 ms. Found 5 JPA repository interfaces.
2023-09-08 23:56:15.492  INFO 1522 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 7896 (http)
2023-09-08 23:56:15.536  INFO 1522 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2023-09-08 23:56:15.537  INFO 1522 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.79]
2023-09-08 23:56:15.782  INFO 1522 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2023-09-08 23:56:15.782  INFO 1522 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 6473 ms
2023-09-08 23:56:16.657  INFO 1522 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [name: default]
2023-09-08 23:56:17.130  INFO 1522 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate ORM core version 5.6.15.Final
2023-09-08 23:56:18.330  INFO 1522 --- [           main] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2023-09-08 23:56:19.136  INFO 1522 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2023-09-08 23:56:20.421  INFO 1522 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
2023-09-08 23:56:20.590  INFO 1522 --- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.MySQL8Dialect
2023-09-08 23:56:25.030  INFO 1522 --- [           main] o.h.e.t.j.p.i.JtaPlatformInitiator       : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2023-09-08 23:56:25.113  INFO 1522 --- [           main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2023-09-08 23:56:26.887  INFO 1522 --- [           main] com.lpvs.service.LPVSLicenseService      : LICENSES: loaded 5 licenses from DB.
2023-09-08 23:56:26.954  INFO 1522 --- [           main] com.lpvs.service.LPVSLicenseService      : LICENSE CONFLICTS: loaded 3 license conflicts from DB.
2023-09-08 23:56:26.957  INFO 1522 --- [           main] com.lpvs.service.LPVSDetectService       : License detection scanner: scanoss
2023-09-08 23:56:28.627  INFO 1522 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 7896 (http) with context path ''
2023-09-08 23:56:28.650  INFO 1522 --- [           main] com.lpvs.LicensePreValidationSystem      : Started LicensePreValidationSystem in 22.494 seconds (JVM running for 24.832)
2023-09-08 23:57:17.633  INFO 1522 --- [nio-7896-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
2023-09-08 23:57:17.635  INFO 1522 --- [nio-7896-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2023-09-08 23:57:17.637  INFO 1522 --- [nio-7896-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 2 ms
2023-09-08 23:57:20.556  INFO 1522 --- [           main] c.l.service.LPVSQueueProcessorService    : PROCESS Webhook id = 1
2023-09-08 23:57:20.560  INFO 1522 --- [  LPVS-ASYNC::1] com.lpvs.service.LPVSQueueService        : GitHub Webhook processing...
2023-09-08 23:57:20.561  INFO 1522 --- [  LPVS-ASYNC::1] com.lpvs.service.LPVSQueueService        : com.lpvs.entity.LPVSQueue@100e5d6
2023-09-08 23:57:41.703 ERROR 1522 --- [  LPVS-ASYNC::1] com.lpvs.service.LPVSQueueService        : Can't authorize commentResults() com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 240 path $.licenses[0]
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 240 path $.licenses[0]
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:397)
        at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:40)
        at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:82)
        at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:61)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.readIntoField(ReflectiveTypeAdapterFactory.java:212)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$FieldReflectionAdapter.readField(ReflectiveTypeAdapterFactory.java:433)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:393)
        at com.google.gson.Gson.fromJson(Gson.java:1227)
        at com.google.gson.Gson.fromJson(Gson.java:1137)
        at com.google.gson.Gson.fromJson(Gson.java:1047)
        at com.google.gson.Gson.fromJson(Gson.java:982)
        at com.lpvs.service.scanner.scanoss.LPVSScanossDetectService.checkLicenses(LPVSScanossDetectService.java:143)
        at com.lpvs.service.LPVSDetectService.runScan(LPVSDetectService.java:44)
        at com.lpvs.service.LPVSQueueService.processWebHook(LPVSQueueService.java:159)
        at com.lpvs.service.LPVSQueueService$$FastClassBySpringCGLIB$$42722be.invoke(<generated>)
        at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:793)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763)
        at org.springframework.aop.interceptor.AsyncExecutionInterceptor.lambda$invoke$0(AsyncExecutionInterceptor.java:115)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 240 path $.licenses[0]
        at com.google.gson.stream.JsonReader.beginObject(JsonReader.java:393)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:386)
        ... 23 more

Screenshots
image

Test environment configuration (please complete the following information):

  • Java: 11
  • LPVS Release: 1.1.0
@o-kopysov o-kopysov added the bug Something isn't working label Sep 8, 2023
@m-rudyk
Copy link
Collaborator

m-rudyk commented Sep 8, 2023

Thank you for reporting this issue. I need more details in order to reproduce this. Currently, LPVS running correctly with example PR, so may I ask you to share details of your repo?
If possible, please give me an access to review PR and configuration, or you may put this Pull request here:
https://github.com/m-rudyk/Debug_LPVS/pulls

image

@kyudori
Copy link
Contributor Author

kyudori commented Sep 9, 2023

First of all when I testing and creating PR, I ran both the old version of LPVS and the LPVS currently in the main branch. And old versions have comments with 'kyudori', and current versions have comments with 'kyudori-test'.

In this PR, both have comments success, but in the current version, the error log appears as follows. Also, in the current version, an unnecessary text '(null)' is entered at the end of the comment.

2023-09-09 08:34:51.563 ERROR 10048 --- [nio-7896-exec-7] com.lpvs.service.LPVSGitHubService       : Can't authorize setPendingCheck()org.kohsuke.github.GHFileNotFoundException: https://api.github.com/repos/kyudori/testlpvs/statuses/7b0f585d75eeb500f031ec3f2d826dfce931ed97 {"message":"Not Found","documentation_url":"https://docs.github.com/rest/commits/statuses#create-a-commit-status"}
2023-09-09 08:34:51.564  INFO 10048 --- [           main] c.l.service.LPVSQueueProcessorService    : PROCESS Webhook id = 20
2023-09-09 08:34:51.568  INFO 10048 --- [  LPVS-ASYNC::3] com.lpvs.service.LPVSQueueService        : GitHub Webhook processing...
2023-09-09 08:34:51.569  INFO 10048 --- [  LPVS-ASYNC::3] com.lpvs.service.LPVSQueueService        : com.lpvs.entity.LPVSQueue@5ed74c1b
2023-09-09 08:35:01.320 ERROR 10048 --- [  LPVS-ASYNC::3] com.lpvs.service.LPVSGitHubService       : Can't authorize commentResults() org.kohsuke.github.GHFileNotFoundException: https://api.github.com/repos/kyudori/testlpvs/statuses/7b0f585d75eeb500f031ec3f2d826dfce931ed97 {"message":"Not Found","documentation_url":"https://docs.github.com/rest/commits/statuses#create-a-commit-status"}
2023-09-09 08:35:01.848 ERROR 10048 --- [  LPVS-ASYNC::3] com.lpvs.service.LPVSGitHubService       : Can't authorize org.kohsuke.github.GHFileNotFoundException: https://api.github.com/repos/kyudori/testlpvs/statuses/7b0f585d75eeb500f031ec3f2d826dfce931ed97 {"message":"Not Found","documentation_url":"https://docs.github.com/rest/commits/statuses#create-a-commit-status"}

In this PR, only the previous version of LPVS has a comment, the current version does not have a comment as Error.

2023-09-09 08:30:27.969  INFO 10048 --- [           main] c.l.service.LPVSQueueProcessorService    : PROCESS Webhook id = 19
2023-09-09 08:30:27.970  INFO 10048 --- [  LPVS-ASYNC::2] com.lpvs.service.LPVSQueueService        : GitHub Webhook processing...
2023-09-09 08:30:27.970  INFO 10048 --- [  LPVS-ASYNC::2] com.lpvs.service.LPVSQueueService        : com.lpvs.entity.LPVSQueue@d5345c59
2023-09-09 08:30:45.190 ERROR 10048 --- [  LPVS-ASYNC::2] com.lpvs.service.LPVSQueueService        : Can't authorize commentResults() com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 240 path $.licenses[0]
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 240 path $.licenses[0]
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:397)
	at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:40)
	at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:82)
	at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:61)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.readIntoField(ReflectiveTypeAdapterFactory.java:212)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$FieldReflectionAdapter.readField(ReflectiveTypeAdapterFactory.java:433)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:393)
	at com.google.gson.Gson.fromJson(Gson.java:1227)
	at com.google.gson.Gson.fromJson(Gson.java:1137)
	at com.google.gson.Gson.fromJson(Gson.java:1047)
	at com.google.gson.Gson.fromJson(Gson.java:982)
	at com.lpvs.service.scanner.scanoss.LPVSScanossDetectService.checkLicenses(LPVSScanossDetectService.java:143)
	at com.lpvs.service.LPVSDetectService.runScan(LPVSDetectService.java:44)
	at com.lpvs.service.LPVSQueueService.processWebHook(LPVSQueueService.java:159)
	at com.lpvs.service.LPVSQueueService$$FastClassBySpringCGLIB$$42722be.invoke(<generated>)
	at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:793)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763)
	at org.springframework.aop.interceptor.AsyncExecutionInterceptor.lambda$invoke$0(AsyncExecutionInterceptor.java:115)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 240 path $.licenses[0]
	at com.google.gson.stream.JsonReader.beginObject(JsonReader.java:393)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:386)
	... 23 more

Thank you for reviewing the issue.
There is a possibility that an error occurred due to a problem with my settings, so I would appreciate it if you could consider this when reviewing it.

@m-rudyk
Copy link
Collaborator

m-rudyk commented Sep 11, 2023

I've replicated this PR here
But I have different behaviour - check finished without error and without result. I'll run more tests to narrow down search.

@m-rudyk
Copy link
Collaborator

m-rudyk commented Sep 12, 2023

First issue cause is found, successfull PR comment here:
https://github.com/m-rudyk/Debug_LPVS/pull/5

Need to adjust unit tests.

@m-rudyk
Copy link
Collaborator

m-rudyk commented Sep 12, 2023

PR in draft, testing different configuration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants