spring-io / spring-asciidoctor-extensions

Asciidoctor Extensions developed by the Spring team
46 stars 18 forks source link

The source location of malformed YAML is hard to identify #60

Open wilkinsona opened 3 years ago

wilkinsona commented 3 years ago

If some config block YAML is malformed, you get a failure like this during doc generation:

Exception in thread "main" org.asciidoctor.gradle.remote.AsciidoctorRemoteExecutionException: Error running Asciidoctor whilst attempting to process /Users/awilkinson/dev/spring-projects/spring-boot/master/spring-boot-project/spring-boot-docs/build/docs/src/asciidoctor/asciidoc/index.singleadoc using backend html5
        at org.asciidoctor.gradle.remote.AsciidoctorJavaExec$_convertFiles_closure4.doCall(AsciidoctorJavaExec.groovy:89)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        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:2330)
        at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2315)
        at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2368)
        at org.asciidoctor.gradle.remote.AsciidoctorJavaExec.convertFiles(AsciidoctorJavaExec.groovy:80)
        at org.asciidoctor.gradle.remote.AsciidoctorJavaExec.access$1(AsciidoctorJavaExec.groovy)
        at org.asciidoctor.gradle.remote.AsciidoctorJavaExec$_run_closure3.doCall(AsciidoctorJavaExec.groovy:72)
        at org.asciidoctor.gradle.remote.AsciidoctorJavaExec$_run_closure3.call(AsciidoctorJavaExec.groovy)
        at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2330)
        at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2315)
        at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2356)
        at org.asciidoctor.gradle.remote.AsciidoctorJavaExec.run(AsciidoctorJavaExec.groovy:67)
        at org.asciidoctor.gradle.remote.AsciidoctorJavaExec.main(AsciidoctorJavaExec.groovy:49)
Caused by: mapping values are not allowed here
 in 'reader', line 3, column 14:
        resources:
                 ^

        at org.yaml.snakeyaml.scanner.ScannerImpl.fetchValue(ScannerImpl.java:869)
        at org.yaml.snakeyaml.scanner.ScannerImpl.fetchMoreTokens(ScannerImpl.java:358)
        at org.yaml.snakeyaml.scanner.ScannerImpl.checkToken(ScannerImpl.java:227)
        at org.yaml.snakeyaml.parser.ParserImpl$ParseBlockMappingKey.produce(ParserImpl.java:558)
        at org.yaml.snakeyaml.parser.ParserImpl.peekEvent(ParserImpl.java:158)
        at org.yaml.snakeyaml.parser.ParserImpl.checkEvent(ParserImpl.java:148)
        at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:235)
        at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:162)
        at org.yaml.snakeyaml.composer.Composer.getNode(Composer.java:95)
        at org.yaml.snakeyaml.constructor.BaseConstructor.getData(BaseConstructor.java:134)
        at org.yaml.snakeyaml.Yaml$1.next(Yaml.java:512)
        at io.spring.asciidoctor.springboot.YamlToPropertiesConverter.convertContent(YamlToPropertiesConverter.java:77)
        at io.spring.asciidoctor.springboot.ConfigurationPropertyValidator.loadProperties(ConfigurationPropertyValidator.java:104)
        at io.spring.asciidoctor.springboot.ConfigurationPropertyValidator.validateProperties(ConfigurationPropertyValidator.java:85)
        at io.spring.asciidoctor.springboot.aj2x.ConfigurationPropertiesTreeprocessor.process(ConfigurationPropertiesTreeprocessor.java:50)
        at io.spring.asciidoctor.springboot.aj2x.ConfigurationPropertiesTreeprocessor.process(ConfigurationPropertiesTreeprocessor.java:56)
        at io.spring.asciidoctor.springboot.aj2x.ConfigurationPropertiesTreeprocessor.process(ConfigurationPropertiesTreeprocessor.java:56)
        at io.spring.asciidoctor.springboot.aj2x.ConfigurationPropertiesTreeprocessor.process(ConfigurationPropertiesTreeprocessor.java:56)
        at io.spring.asciidoctor.springboot.aj2x.ConfigurationPropertiesTreeprocessor.process(ConfigurationPropertiesTreeprocessor.java:56)
        at io.spring.asciidoctor.springboot.aj2x.ConfigurationPropertiesTreeprocessor.process(ConfigurationPropertiesTreeprocessor.java:56)
        at io.spring.asciidoctor.springboot.aj2x.ConfigurationPropertiesTreeprocessor.process(ConfigurationPropertiesTreeprocessor.java:44)
        at org.asciidoctor.jruby.extension.processorproxies.TreeprocessorProxy.process(TreeprocessorProxy.java:95)
        at org.asciidoctor.jruby.extension.processorproxies.TreeprocessorProxy$INVOKER$i$1$0$process.call(TreeprocessorProxy$INVOKER$i$1$0$process.gen)
        at org.jruby.internal.runtime.methods.JavaMethod$JavaMethodOneOrN.call(JavaMethod.java:958)
        at org.jruby.RubyMethod.call(RubyMethod.java:119)
        at org.jruby.RubyMethod$INVOKER$i$call.call(RubyMethod$INVOKER$i$call.gen)
        at org.jruby.internal.runtime.methods.JavaMethod$JavaMethodZeroOrOneOrNBlock.call(JavaMethod.java:349)
        at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:375)
        at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:174)
        at org.jruby.ir.interpreter.InterpreterEngine.processCall(InterpreterEngine.java:316)
        at org.jruby.ir.interpreter.StartupInterpreterEngine.interpret(StartupInterpreterEngine.java:72)
        at org.jruby.ir.interpreter.Interpreter.INTERPRET_BLOCK(Interpreter.java:116)
        at org.jruby.runtime.MixedModeIRBlockBody.commonYieldPath(MixedModeIRBlockBody.java:137)
        at org.jruby.runtime.IRBlockBody.doYield(IRBlockBody.java:166)
        at org.jruby.runtime.BlockBody.yield(BlockBody.java:108)
        at org.jruby.runtime.Block.yield(Block.java:184)
        at org.jruby.RubyArray.each(RubyArray.java:1809)
        at org.jruby.RubyArray$INVOKER$i$0$0$each.call(RubyArray$INVOKER$i$0$0$each.gen)
        at org.jruby.internal.runtime.methods.JavaMethod$JavaMethodZeroBlock.call(JavaMethod.java:555)
        at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:332)
        at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:86)
        at org.jruby.runtime.callsite.CachingCallSite.callIter(CachingCallSite.java:93)
        at org.jruby.ir.instructions.CallBase.interpret(CallBase.java:546)
        at org.jruby.ir.interpreter.InterpreterEngine.processCall(InterpreterEngine.java:361)
        at org.jruby.ir.interpreter.StartupInterpreterEngine.interpret(StartupInterpreterEngine.java:72)
        at org.jruby.ir.interpreter.InterpreterEngine.interpret(InterpreterEngine.java:80)
        at org.jruby.internal.runtime.methods.MixedModeIRMethod.INTERPRET_METHOD(MixedModeIRMethod.java:121)
        at org.jruby.internal.runtime.methods.MixedModeIRMethod.call(MixedModeIRMethod.java:108)
        at org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:192)
        at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:354)
        at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:143)
        at org.jruby.ir.interpreter.InterpreterEngine.processCall(InterpreterEngine.java:345)
        at org.jruby.ir.interpreter.StartupInterpreterEngine.interpret(StartupInterpreterEngine.java:72)
        at org.jruby.ir.interpreter.InterpreterEngine.interpret(InterpreterEngine.java:92)
        at org.jruby.internal.runtime.methods.MixedModeIRMethod.INTERPRET_METHOD(MixedModeIRMethod.java:191)
        at org.jruby.internal.runtime.methods.MixedModeIRMethod.call(MixedModeIRMethod.java:178)
        at org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:208)
        at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:396)
        at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:205)
        at org.jruby.ir.interpreter.InterpreterEngine.processCall(InterpreterEngine.java:325)
        at org.jruby.ir.interpreter.StartupInterpreterEngine.interpret(StartupInterpreterEngine.java:72)
        at org.jruby.ir.interpreter.InterpreterEngine.interpret(InterpreterEngine.java:92)
        at org.jruby.internal.runtime.methods.MixedModeIRMethod.INTERPRET_METHOD(MixedModeIRMethod.java:191)
        at org.jruby.internal.runtime.methods.MixedModeIRMethod.call(MixedModeIRMethod.java:178)
        at org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:208)
        at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:396)
        at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:205)
        at org.jruby.ir.interpreter.InterpreterEngine.processCall(InterpreterEngine.java:325)
        at org.jruby.ir.interpreter.StartupInterpreterEngine.interpret(StartupInterpreterEngine.java:72)
        at org.jruby.ir.interpreter.Interpreter.INTERPRET_BLOCK(Interpreter.java:116)
        at org.jruby.runtime.MixedModeIRBlockBody.commonYieldPath(MixedModeIRBlockBody.java:137)
        at org.jruby.runtime.IRBlockBody.doYield(IRBlockBody.java:166)
        at org.jruby.runtime.BlockBody.yield(BlockBody.java:108)
        at org.jruby.runtime.Block.yield(Block.java:184)
        at org.jruby.RubyIO.ensureYieldClose(RubyIO.java:1164)
        at org.jruby.RubyIO.open(RubyIO.java:1158)
        at org.jruby.RubyIO$INVOKER$s$0$0$open.call(RubyIO$INVOKER$s$0$0$open.gen)
        at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:332)
        at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:86)
        at org.jruby.runtime.callsite.CachingCallSite.callIter(CachingCallSite.java:93)
        at org.jruby.ir.instructions.CallBase.interpret(CallBase.java:546)
        at org.jruby.ir.interpreter.InterpreterEngine.processCall(InterpreterEngine.java:361)
        at org.jruby.ir.interpreter.StartupInterpreterEngine.interpret(StartupInterpreterEngine.java:72)
        at org.jruby.internal.runtime.methods.MixedModeIRMethod.INTERPRET_METHOD(MixedModeIRMethod.java:86)
        at org.jruby.internal.runtime.methods.MixedModeIRMethod.call(MixedModeIRMethod.java:73)
        at org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:174)
        at org.jruby.RubyClass.finvoke(RubyClass.java:812)
        at org.jruby.runtime.Helpers.invoke(Helpers.java:464)
        at org.jruby.RubyBasicObject.callMethod(RubyBasicObject.java:376)
        at org.asciidoctor.jruby.internal.JRubyAsciidoctor.convertFile(JRubyAsciidoctor.java:390)
        at org.asciidoctor.jruby.internal.JRubyAsciidoctor.convertFile(JRubyAsciidoctor.java:366)
        at org.asciidoctor.gradle.remote.AsciidoctorJavaExec$_convertFiles_closure4.doCall(AsciidoctorJavaExec.groovy:85)
        ... 22 more

It's not easy to identify the source of the problem. I can see that it's line 3 of some YAML somewhere, but that's about it. In this case the problem was due to a missing : at the end of the previous line. If possible, we should try to include some information about the location of the YAML in the source .adoc file to make the problem easier to fix.

I think we should also consider catching the exception and logging an error. I don't think we should include the stacktrace as it doesn't add much.