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

Single string "author" field leads to MismatchedInputException: Cannot construct instance of Person #5

Closed
JohT opened this issue Jul 27, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@JohT
Copy link

JohT commented Jul 27, 2024

Hi 👋,

i've got the following error message when trying to scan react-router-6.24.0 router package.json.
Attached as file directly: package.json

StackTrace

2024-07-27 08:02:28.937 [main] WARN ScannerImpl - Cannot scan item /npm-package-json/packages/router/package.json
com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of `org.jqassistant.plugin.npm.impl.scanner.Package$Person` (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('Remix Software <[email protected]>')
 at [Source: (com.buschmais.jqassistant.plugin.common.impl.scanner.BufferedFileResource$BufferStream); line: 16, column: 13] (through reference chain: org.jqassistant.plugin.npm.impl.scanner.Package["author"])
        at com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:63)
        at com.fasterxml.jackson.databind.DeserializationContext.reportInputMismatch(DeserializationContext.java:1739)
        at com.fasterxml.jackson.databind.DeserializationContext.handleMissingInstantiator(DeserializationContext.java:1364)
        at com.fasterxml.jackson.databind.deser.std.StdDeserializer._deserializeFromString(StdDeserializer.java:311)
        at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromString(BeanDeserializerBase.java:1504)
        at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeOther(BeanDeserializer.java:197)
        at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:187)
        at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:129)
        at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:314)
        at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:177)
        at com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:323)
        at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4825)
        at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3809)
        at org.jqassistant.plugin.npm.impl.scanner.PackageJsonScannerPlugin.scan(PackageJsonScannerPlugin.java:44)
        at org.jqassistant.plugin.npm.impl.scanner.PackageJsonScannerPlugin.scan(PackageJsonScannerPlugin.java:27)
        at com.buschmais.jqassistant.core.scanner.impl.ScannerImpl.scan(ScannerImpl.java:125)
        at com.buschmais.jqassistant.core.scanner.impl.ScannerImpl.scan(ScannerImpl.java:88)
        at com.buschmais.jqassistant.core.scanner.impl.ScannerImpl.scan(ScannerImpl.java:63)
        at com.buschmais.jqassistant.plugin.common.api.scanner.AbstractContainerScannerPlugin.scan(AbstractContainerScannerPlugin.java:53)
        at com.buschmais.jqassistant.plugin.common.api.scanner.AbstractContainerScannerPlugin.scan(AbstractContainerScannerPlugin.java:29)
        at com.buschmais.jqassistant.core.scanner.impl.ScannerImpl.scan(ScannerImpl.java:125)
        at com.buschmais.jqassistant.core.scanner.impl.ScannerImpl.scan(ScannerImpl.java:84)
        at com.buschmais.jqassistant.core.scanner.impl.ScannerImpl.scan(ScannerImpl.java:63)
        at com.buschmais.jqassistant.commandline.task.ScanTask.scan(ScanTask.java:103)
        at com.buschmais.jqassistant.commandline.task.ScanTask.lambda$scanFiles$4(ScanTask.java:93)
        at java.base/java.util.Optional.ifPresent(Optional.java:178)
        at com.buschmais.jqassistant.commandline.task.ScanTask.scanFiles(ScanTask.java:83)
        at com.buschmais.jqassistant.commandline.task.ScanTask.lambda$run$0(ScanTask.java:61)
        at java.base/java.util.Optional.ifPresentOrElse(Optional.java:196)
        at com.buschmais.jqassistant.commandline.task.ScanTask.lambda$run$2(ScanTask.java:60)
        at com.buschmais.jqassistant.commandline.task.AbstractStoreTask.withStore(AbstractStoreTask.java:50)
        at com.buschmais.jqassistant.commandline.task.ScanTask.run(ScanTask.java:51)
        at com.buschmais.jqassistant.commandline.Main.executeTask(Main.java:320)
        at com.buschmais.jqassistant.commandline.Main.executeTasks(Main.java:278)
        at com.buschmais.jqassistant.commandline.Main.interpretCommandLine(Main.java:204)
        at com.buschmais.jqassistant.commandline.Main.run(Main.java:82)
        at com.buschmais.jqassistant.commandline.Main.main(Main.java:63)

Plugin Configuration

This is my plugins configuration inside the jqassistant yaml file:

  plugins:
    - group-id: org.jqassistant.plugin.typescript
      artifact-id: jqassistant-typescript-plugin
      version: 1.0.0-RC1
    - group-id: org.jqassistant.plugin
      artifact-id: jqassistant-npm-plugin
      version: 2.0.0

These are my plugins:

024-07-27 08:02:26.706 [main] INFO PluginRepositoryImpl - jQAssistant Core Analysis Plugin 2.3.1 [jqa.core.analysis.plugin]
2024-07-27 08:02:26.706 [main] INFO PluginRepositoryImpl - jQAssistant Core Report Plugin 2.3.1 [jqa.core.report.plugin]
2024-07-27 08:02:26.706 [main] INFO PluginRepositoryImpl - jQAssistant Common Plugin 2.3.1 [jqa.plugin.common]
2024-07-27 08:02:26.707 [main] INFO PluginRepositoryImpl - jQAssistant Java Plugin 2.3.1 [jqa.plugin.java]
2024-07-27 08:02:26.707 [main] INFO PluginRepositoryImpl - jQAssistant JSON Plugin 2.3.1 [jqa.plugin.json]
2024-07-27 08:02:26.707 [main] INFO PluginRepositoryImpl - jQAssistant JUnit Plugin 2.3.1 [jqa.plugin.junit]
2024-07-27 08:02:26.707 [main] INFO PluginRepositoryImpl - jQAssistant Maven 3 Plugin 2.3.1 [jqa.plugin.maven3]
2024-07-27 08:02:26.707 [main] INFO PluginRepositoryImpl - jQAssistant NPM Plugin <unknown version> [jqa.plugin.npm]
2024-07-27 08:02:26.707 [main] INFO PluginRepositoryImpl - jQAssistant XML Plugin 2.3.1 [jqa.plugin.xml]
2024-07-27 08:02:26.707 [main] INFO PluginRepositoryImpl - jQAssistant YAML 2 Plugin 2.3.1 [jqa.plugin.yaml2]
2024-07-27 08:02:26.707 [main] INFO PluginRepositoryImpl - jQAssistant Typescript Plugin <unknown version> [jqassistant.plugin.typescript]

jQAssistant Version

I'm using jqassistant-commandline-neo4jv5-2.3.1-distribution.zip on Mac.

Idea

Thanks 🙏

JohT added a commit to JohT/code-graph-analysis-pipeline that referenced this issue Jul 27, 2024
@JohT
Copy link
Author

JohT commented Jul 27, 2024

Something similar might also apply to the field "contributors". Here is the error message I get when scanning package.json of ant-design:

com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of `org.jqassistant.plugin.npm.impl.scanner.Package$Person` (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('ant')
 at [Source: (com.buschmais.jqassistant.plugin.common.impl.scanner.BufferedFileResource$BufferStream); line: 30, column: 5] (through reference chain: org.jqassistant.plugin.npm.impl.scanner.Package["contributors"]->java.util.ArrayList[0])
        at com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:63)
        at com.fasterxml.jackson.databind.DeserializationContext.reportInputMismatch(DeserializationContext.java:1739)
        at com.fasterxml.jackson.databind.DeserializationContext.handleMissingInstantiator(DeserializationContext.java:1364)
        at com.fasterxml.jackson.databind.deser.std.StdDeserializer._deserializeFromString(StdDeserializer.java:311)
        at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromString(BeanDeserializerBase.java:1504)
        at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeOther(BeanDeserializer.java:197)
        at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:187)
        at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer._deserializeFromArray(CollectionDeserializer.java:359)
        at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:244)
        at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:28)
        at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:129)
        at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:314)
        at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:177)
        at com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:323)
        at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4825)
        at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3809)
        at org.jqassistant.plugin.npm.impl.scanner.PackageJsonScannerPlugin.scan(PackageJsonScannerPlugin.java:44)
        at org.jqassistant.plugin.npm.impl.scanner.PackageJsonScannerPlugin.scan(PackageJsonScannerPlugin.java:27)
        at com.buschmais.jqassistant.core.scanner.impl.ScannerImpl.scan(ScannerImpl.java:125)
        at com.buschmais.jqassistant.core.scanner.impl.ScannerImpl.scan(ScannerImpl.java:88)
        at com.buschmais.jqassistant.core.scanner.impl.ScannerImpl.scan(ScannerImpl.java:63)
        at com.buschmais.jqassistant.plugin.common.api.scanner.AbstractContainerScannerPlugin.scan(AbstractContainerScannerPlugin.java:53)
        at com.buschmais.jqassistant.plugin.common.api.scanner.AbstractContainerScannerPlugin.scan(AbstractContainerScannerPlugin.java:29)
        at com.buschmais.jqassistant.core.scanner.impl.ScannerImpl.scan(ScannerImpl.java:125)
        at com.buschmais.jqassistant.core.scanner.impl.ScannerImpl.scan(ScannerImpl.java:84)
        at com.buschmais.jqassistant.core.scanner.impl.ScannerImpl.scan(ScannerImpl.java:63)
        at com.buschmais.jqassistant.commandline.task.ScanTask.scan(ScanTask.java:103)
        at com.buschmais.jqassistant.commandline.task.ScanTask.lambda$scanFiles$4(ScanTask.java:93)
        at java.base/java.util.Optional.ifPresent(Optional.java:178)
        at com.buschmais.jqassistant.commandline.task.ScanTask.scanFiles(ScanTask.java:83)
        at com.buschmais.jqassistant.commandline.task.ScanTask.lambda$run$0(ScanTask.java:61)
        at java.base/java.util.Optional.ifPresentOrElse(Optional.java:196)
        at com.buschmais.jqassistant.commandline.task.ScanTask.lambda$run$2(ScanTask.java:60)
        at com.buschmais.jqassistant.commandline.task.AbstractStoreTask.withStore(AbstractStoreTask.java:50)
        at com.buschmais.jqassistant.commandline.task.ScanTask.run(ScanTask.java:51)
        at com.buschmais.jqassistant.commandline.Main.executeTask(Main.java:320)
        at com.buschmais.jqassistant.commandline.Main.executeTasks(Main.java:278)
        at com.buschmais.jqassistant.commandline.Main.interpretCommandLine(Main.java:204)
        at com.buschmais.jqassistant.commandline.Main.run(Main.java:82)
        at com.buschmais.jqassistant.commandline.Main.main(Main.java:63)

JohT added a commit to JohT/code-graph-analysis-pipeline that referenced this issue Jul 27, 2024
@DirkMahler DirkMahler added the bug Something isn't working label Jul 28, 2024
@hmozaffari
Copy link

I also noticed some package.json files are not 100% compliant and plugin skips scanning the whole package.json file. Surprisigly npm itself somehow ignores those imperfect elements of package.json file but doesn't reject the file.

I was wondering if scanner can have same approach. If there is an element like "author" which doesn't match with schema, it ignores it and show the warning but contine scanning the package.json file.

@JohT
Copy link
Author

JohT commented Oct 23, 2024

@hmozaffari, i'd prefer to first support the standard and having an option comparable to the "continue-on-error" separately.

A fail fast approach makes it possible to uncover issues like thi. Ignoring/Skipping issues would make it hard to find those kind of bugs. For example, in this case, someone would most probably not even think about the "author" field or that it is always empty. This would be hard to detect and debug. A clear and early error message is a pity at first glance, but will eventually safe you a lot of time and give you an overall better quality

@SebastianWendorf
Copy link
Contributor

Fixed with #11

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
4 participants