demonnic / muddler

A build tool for Mudlet package developers
MIT License
40 stars 12 forks source link

Exception should name broken file #10

Closed Kebap closed 3 years ago

Kebap commented 3 years ago

I ran muddler, obviously did some error with a bracket, but do not receive a file name for reference. Where should I start looking?

This is what I found:

Run demonnic/build-with-muddler@main
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100   629  100   629    0     0   7313      0 --:--:-- --:--:-- --:--:--  7313

100 12.7M  100 12.7M    0     0  39.9M      0 --:--:-- --:--:-- --:--:-- 39.9M
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.codehaus.groovy.vmplugin.v7.Java7$1 (file:/home/runner/work/mg-muddler/mg-muddler/muddler/lib/muddle-0.5-all.jar) to constructor java.lang.invoke.MethodHandles$Lookup(java.lang.Class,int)
WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.vmplugin.v7.Java7$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Using Muddler version: 0.5
     [copy] Copying 3 files to /home/runner/work/mg-muddler/mg-muddler/build/filtered/src
Exception in thread "main" groovy.json.JsonException: Unable to determine the current character, it is not a string, number, array, or object

The current character read is ']' with an int value of 93
Unable to determine the current character, it is not a string, number, array, or object
line number 73
index number 1602
    ],
....^
    at org.apache.groovy.json.internal.JsonParserCharArray.decodeValueInternal(JsonParserCharArray.java:202)
    at org.apache.groovy.json.internal.JsonParserCharArray.decodeJsonArray(JsonParserCharArray.java:322)
    at org.apache.groovy.json.internal.JsonParserCharArray.decodeValueInternal(JsonParserCharArray.java:178)
    at org.apache.groovy.json.internal.JsonParserCharArray.decodeJsonObject(JsonParserCharArray.java:128)
    at org.apache.groovy.json.internal.JsonParserCharArray.decodeValueInternal(JsonParserCharArray.java:182)
    at org.apache.groovy.json.internal.JsonParserCharArray.decodeJsonArray(JsonParserCharArray.java:322)
    at org.apache.groovy.json.internal.JsonParserCharArray.decodeValueInternal(JsonParserCharArray.java:178)
    at org.apache.groovy.json.internal.JsonParserCharArray.decodeValue(JsonParserCharArray.java:153)
    at org.apache.groovy.json.internal.JsonParserCharArray.decodeFromChars(JsonParserCharArray.java:42)
Muddler build failed with exit status: 1
    at org.apache.groovy.json.internal.JsonParserCharArray.parse(JsonParserCharArray.java:380)
    at org.apache.groovy.json.internal.BaseJsonParser.parse(BaseJsonParser.java:131)
    at org.apache.groovy.json.internal.BaseJsonParser.parse(BaseJsonParser.java:154)
    at groovy.json.JsonSlurper.parseFile(JsonSlurper.java:362)
    at groovy.json.JsonSlurper.parse(JsonSlurper.java:345)
    at groovy.json.JsonSlurper$parse.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:115)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:127)
    at muddler.mudlet.packages.Package$_createItems_closure3.doCall(Package.groovy:46)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:101)
    at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:323)
    at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:263)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1041)
    at groovy.lang.Closure.call(Closure.java:405)
    at groovy.lang.Closure.call(Closure.java:421)
    at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2296)
    at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2281)
    at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2322)
    at org.codehaus.groovy.runtime.dgm$186.invoke(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:244)
    at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:53)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:115)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:127)
    at muddler.mudlet.packages.Package.createItems(Package.groovy:39)
    at muddler.mudlet.packages.Package.<init>(Package.groovy:20)
    at muddler.mudlet.packages.TriggerPackage.<init>(TriggerPackage.groovy:8)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
    at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:80)
    at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:105)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:59)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:237)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:241)
    at muddler.App.main(App.groovy:56)
Error: Process completed with exit code 1.
Kebap commented 3 years ago

This was the culprit:

"patterns": [ 
      {
        "pattern": "Du sagst:", 
        "type": "substring",
      },
  ],

Note the trailing comma which seems fair in Lua but no-no in Json

Kebap commented 3 years ago

Here is another strange exception message that did not help at all in identifying the error source. Can you guess it before looking below?

Exception reads:

Run demonnic/build-with-muddler@main
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
Using Muddler version: 0.6
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100   629  100   629    0     0   6353      0 --:--:-- --:--:-- --:--:--  6353

  3 18.0M    3  710k    0     0  3159k      0  0:00:05 --:--:--  0:00:05 3159k
100 18.0M  100 18.0M    0     0  35.6M      0 --:--:-- --:--:-- --:--:-- 61.8M
     [copy] Copying 8 files to /home/runner/work/mg-muddler/mg-muddler/build/filtered/src
Exception in thread "main" groovy.json.JsonException: Unable to decode string
    at org.apache.groovy.json.internal.CharBuf.decodeJsonString(CharBuf.java:824)
    at org.apache.groovy.json.internal.JsonParserCharArray.decodeString(JsonParserCharArray.java:285)
    at org.apache.groovy.json.internal.JsonParserCharArray.decodeValueInternal(JsonParserCharArray.java:162)
    at org.apache.groovy.json.internal.JsonParserCharArray.decodeJsonObject(JsonParserCharArray.java:128)
    at org.apache.groovy.json.internal.JsonParserCharArray.decodeValueInternal(JsonParserCharArray.java:182)
    at org.apache.groovy.json.internal.JsonParserCharArray.decodeJsonArray(JsonParserCharArray.java:322)
    at org.apache.groovy.json.internal.JsonParserCharArray.decodeValueInternal(JsonParserCharArray.java:178)
    at org.apache.groovy.json.internal.JsonParserCharArray.decodeJsonObject(JsonParserCharArray.java:128)
    at org.apache.groovy.json.internal.JsonParserCharArray.decodeValueInternal(JsonParserCharArray.java:182)
    at org.apache.groovy.json.internal.JsonParserCharArray.decodeJsonArray(JsonParserCharArray.java:322)
    at org.apache.groovy.json.internal.JsonParserCharArray.decodeValueInternal(JsonParserCharArray.java:178)
    at org.apache.groovy.json.internal.JsonParserCharArray.decodeValue(JsonParserCharArray.java:153)
    at org.apache.groovy.json.internal.JsonParserCharArray.decodeFromChars(JsonParserCharArray.java:43)
    at org.apache.groovy.json.internal.JsonParserCharArray.parse(JsonParserCharArray.java:380)
    at org.apache.groovy.json.internal.BaseJsonParser.parse(BaseJsonParser.java:133)
    at org.apache.groovy.json.internal.BaseJsonParser.parse(BaseJsonParser.java:156)
    at groovy.json.JsonSlurper.parseFile(JsonSlurper.java:362)
    at groovy.json.JsonSlurper.parse(JsonSlurper.java:345)
    at groovy.json.JsonSlurper$parse.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:139)
    at muddler.mudlet.packages.Package$_createItems_closure3.doCall(Package.groovy:46)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:107)
    at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:323)
    at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:263)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1029)
    at groovy.lang.Closure.call(Closure.java:412)
    at groovy.lang.Closure.call(Closure.java:428)
    at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2318)
    at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2303)
    at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2344)
    at org.codehaus.groovy.runtime.dgm$200.invoke(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:247)
    at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:56)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:139)
    at muddler.mudlet.packages.Package.createItems(Package.groovy:39)
    at muddler.mudlet.packages.Package.<init>(Package.groovy:20)
    at muddler.mudlet.packages.TriggerPackage.<init>(TriggerPackage.groovy:8)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
    at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:72)
    at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:105)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:59)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:263)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:268)
    at muddler.App.main(App.groovy:69)
Muddler build failed with exit status: 1
Error: Process completed with exit code 1.

Culprit was:

One new trigger in triggers.json received one new pattern of type regex (that is, in between lots other changes in the commit, so not easy to spot) which had this very pattern: ^Du hast \d* neuen? Briefe? im Postamt liegen\.$

This seems to not get recognized, even though neither \d or . are legit escape sequences in json. Probably every single \ needs to be escaped?

Testing with adjusted pattern ^Du hast \\d* neuen? Briefe? im Postamt liegen\\.$ seems to work fine then.

Looking back at the docs, escaping the / character in regex is indeed mentioned on Aliases wiki page, but is not on Triggers page, which is the item I tackled first instead. Obviously beginner error, as any json veteran would know to change the scring, but maybe could receive a noob friendly message instead of the gibberish exception?

demonnic commented 3 years ago

Yeah, muddler currently doesn't really do any error handling. This seems as good a place as any to start on it. Thanks for the issue.

demonnic commented 3 years ago

Fixed in 0.7