Closed feliksik closed 3 months ago
@feliksik fixed and released as 0.17.0
You are great, thanks!
It turns out that text2confl also needs to catch a JsonMappingException;
When any variable is enclosed in [
and ]
, that's the one that's thrown:
Exception in thread "main" com.fasterxml.jackson.databind.JsonMappingException: Unrecognized token 'x': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')
at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1, column: 3] (through reference chain: java.util.ArrayList[0])
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:402)
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:373)
at com.fasterxml.jackson.databind.deser.std.StringCollectionDeserializer.deserialize(StringCollectionDeserializer.java:223)
at com.fasterxml.jackson.databind.deser.std.StringCollectionDeserializer.deserialize(StringCollectionDeserializer.java:184)
at com.fasterxml.jackson.databind.deser.std.StringCollectionDeserializer.deserialize(StringCollectionDeserializer.java:27)
at com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:342)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4905)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3848)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3831)
at com.github.zeldigas.text2confl.convert.PageAttributesKt.parseAttribute(PageAttributes.kt:36)
at com.github.zeldigas.text2confl.convert.asciidoc.AsciidocFileConverter.toHeader(AsciidocFileConverter.kt:20)
at com.github.zeldigas.text2confl.convert.asciidoc.AsciidocFileConverter.readHeader(AsciidocFileConverter.kt:16)
at com.github.zeldigas.text2confl.convert.UniversalConverter.scanDocuments$lambda$6(Converter.kt:113)
at com.github.zeldigas.text2confl.convert.FileNameBasedDetector.scanDirectoryRecursively(PagesDetector.kt:29)
at com.github.zeldigas.text2confl.convert.FileNameBasedDetector.scanDirectoryRecursively(PagesDetector.kt:32)
at com.github.zeldigas.text2confl.convert.FileNameBasedDetector.scanDirectoryRecursively(PagesDetector.kt:32)
at com.github.zeldigas.text2confl.convert.UniversalConverter.scanDocuments(Converter.kt:110)
at com.github.zeldigas.text2confl.convert.UniversalConverter.convertDir(Converter.kt:79)
at com.github.zeldigas.text2confl.cli.Upload.tryUpload(Upload.kt:89)
at com.github.zeldigas.text2confl.cli.Upload.access$tryUpload(Upload.kt:27)
at com.github.zeldigas.text2confl.cli.Upload$run$1.invokeSuspend(Upload.kt:74)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:277)
at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:95)
at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:69)
at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:48)
at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)
at com.github.zeldigas.text2confl.cli.Upload.run(Upload.kt:71)
at com.github.ajalt.clikt.parsers.Parser.finalizeAndRun(Parser.kt:348)
at com.github.ajalt.clikt.parsers.Parser.parse(Parser.kt:218)
at com.github.ajalt.clikt.parsers.Parser.parse(Parser.kt:245)
at com.github.ajalt.clikt.parsers.Parser.parse(Parser.kt:42)
at com.github.ajalt.clikt.core.CliktCommand.parse(CliktCommand.kt:457)
at com.github.ajalt.clikt.core.CliktCommand.parse$default(CliktCommand.kt:454)
at com.github.ajalt.clikt.core.CliktCommand.main(CliktCommand.kt:474)
at com.github.ajalt.clikt.core.CliktCommand.main(CliktCommand.kt:481)
at com.github.zeldigas.text2confl.cli.MainKt.main(Main.kt:42)
I actually ran into this when using some plantUML in a variable.
Fixed in 0.17.1
Actual Behavior
The following document makes text2confl crash:
Expected Behavior
One can use a variable to start the title, as this is valid asciidoc.
Second thing is that if something unexpected fails, the exception mentions the .adoc file that triggered the failure.
Analysis
Cause
The attributes are parsed here. The assumption that the "{" delimiter indicates yaml/json is not correct: it might well be templated asciidoc.
However, I'm not yet exactly sure why this works:
It has to do with the fact that asciidoctor is using the header-0
= {my-product}
to set the :title: attribute, which is consequently parsed by text2conf.It would be useful to use a title from a variable.
Workaround
Use a
prefix for title: