When using the swagger parser, we received the below log warning message[2] when we have a pattern regular value with syntax errors[1]. This error log is kind of confusing at a glance it looks like the tool was crashing.
I wonder whether we can have any simple detailed error message for this instead of this warning.
May 09, 2023 1:51:21 PM io.swagger.v3.parser.util.DeserializationUtils readYamlTree
WARNING: Error snake-parsing yaml content
io.swagger.v3.parser.util.DeserializationUtils$SnakeException: Exception safe-checking yaml content (maxDepth 2000, maxYamlAliasesForCollections 2147483647)
at io.swagger.v3.parser.util.DeserializationUtils$CustomSnakeYamlConstructor.getSingleData(DeserializationUtils.java:438)
at org.yaml.snakeyaml.Yaml.loadFromReader(Yaml.java:477)
at org.yaml.snakeyaml.Yaml.load(Yaml.java:406)
at io.swagger.v3.parser.util.DeserializationUtils.readYamlTree(DeserializationUtils.java:211)
at io.swagger.v3.parser.util.DeserializationUtils.deserializeIntoTree(DeserializationUtils.java:143)
at io.swagger.v3.parser.OpenAPIV3Parser.readContents(OpenAPIV3Parser.java:168)
at io.swagger.v3.parser.OpenAPIV3Parser.readContents(OpenAPIV3Parser.java:107)
at io.swagger.parser.OpenAPIParser.readContents(OpenAPIParser.java:29)
at io.ballerina.openapi.core.GeneratorUtils.getOpenAPIFromOpenAPIV3Parser(GeneratorUtils.java:436)
at io.ballerina.openapi.core.GeneratorUtils.normalizeOpenAPI(GeneratorUtils.java:734)
at io.ballerina.openapi.cmd.BallerinaCodeGenerator.generateClientFiles(BallerinaCodeGenerator.java:333)
at io.ballerina.openapi.cmd.BallerinaCodeGenerator.generateClient(BallerinaCodeGenerator.java:215)
at io.ballerina.openapi.cmd.OpenApiCmd.generatesClientFile(OpenApiCmd.java:355)
at io.ballerina.openapi.cmd.OpenApiCmd.openApiToBallerina(OpenApiCmd.java:283)
at io.ballerina.openapi.cmd.OpenApiCmd.execute(OpenApiCmd.java:183)
at java.base/java.util.Optional.ifPresent(Optional.java:183)
at io.ballerina.cli.launcher.Main.main(Main.java:51)
Caused by: while scanning a double-quoted scalar
in 'string', line 71, column 20:
pattern: "[a-zA-Z0-9,\\.\']"
^
found unknown escape character '(39)
in 'string', line 71, column 36:
pattern: "[a-zA-Z0-9,\\.\']"
^
at org.yaml.snakeyaml.scanner.ScannerImpl.scanFlowScalarNonSpaces(ScannerImpl.java:1962)
at org.yaml.snakeyaml.scanner.ScannerImpl.scanFlowScalar(ScannerImpl.java:1895)
at org.yaml.snakeyaml.scanner.ScannerImpl.fetchFlowScalar(ScannerImpl.java:1075)
at org.yaml.snakeyaml.scanner.ScannerImpl.fetchDouble(ScannerImpl.java:1057)
at org.yaml.snakeyaml.scanner.ScannerImpl.fetchMoreTokens(ScannerImpl.java:445)
at org.yaml.snakeyaml.scanner.ScannerImpl.checkToken(ScannerImpl.java:256)
at org.yaml.snakeyaml.parser.ParserImpl$ParseBlockMappingValue.produce(ParserImpl.java:680)
at org.yaml.snakeyaml.parser.ParserImpl.peekEvent(ParserImpl.java:171)
at org.yaml.snakeyaml.comments.CommentEventsCollector$1.peek(CommentEventsCollector.java:57)
at org.yaml.snakeyaml.comments.CommentEventsCollector$1.peek(CommentEventsCollector.java:43)
at org.yaml.snakeyaml.comments.CommentEventsCollector.collectEvents(CommentEventsCollector.java:136)
at org.yaml.snakeyaml.comments.CommentEventsCollector.collectEvents(CommentEventsCollector.java:116)
at org.yaml.snakeyaml.composer.Composer.composeScalarNode(Composer.java:221)
at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:190)
at org.yaml.snakeyaml.composer.Composer.composeKeyNode(Composer.java:317)
at org.yaml.snakeyaml.composer.Composer.composeMappingChildren(Composer.java:308)
at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:293)
at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:194)
at org.yaml.snakeyaml.composer.Composer.composeValueNode(Composer.java:321)
at org.yaml.snakeyaml.composer.Composer.composeMappingChildren(Composer.java:312)
at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:293)
at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:194)
at org.yaml.snakeyaml.composer.Composer.composeValueNode(Composer.java:321)
at org.yaml.snakeyaml.composer.Composer.composeMappingChildren(Composer.java:312)
at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:293)
at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:194)
at org.yaml.snakeyaml.composer.Composer.composeValueNode(Composer.java:321)
at org.yaml.snakeyaml.composer.Composer.composeMappingChildren(Composer.java:312)
at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:293)
at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:194)
at org.yaml.snakeyaml.composer.Composer.composeValueNode(Composer.java:321)
at org.yaml.snakeyaml.composer.Composer.composeMappingChildren(Composer.java:312)
at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:293)
at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:194)
at org.yaml.snakeyaml.composer.Composer.composeValueNode(Composer.java:321)
at org.yaml.snakeyaml.composer.Composer.composeMappingChildren(Composer.java:312)
at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:293)
at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:194)
at org.yaml.snakeyaml.composer.Composer.getNode(Composer.java:116)
at org.yaml.snakeyaml.composer.Composer.getSingleNode(Composer.java:142)
at io.swagger.v3.parser.util.DeserializationUtils$CustomSnakeYamlConstructor.getSingleData(DeserializationUtils.java:415)
... 16 more
May 09, 2023 1:51:21 PM io.swagger.v3.parser.util.DeserializationUtils readYamlTree
SEVERE: Error parsing content
com.fasterxml.jackson.dataformat.yaml.snakeyaml.error.MarkedYAMLException: while scanning a double-quoted scalar
in 'reader', line 71, column 20:
pattern: "[a-zA-Z0-9,\\.\']"
^
found unknown escape character '(39)
in 'reader', line 71, column 36:
pattern: "[a-zA-Z0-9,\\.\']"
^
at [Source: (StringReader); line: 71, column: 18]
at com.fasterxml.jackson.dataformat.yaml.snakeyaml.error.MarkedYAMLException.from(MarkedYAMLException.java:28)
at com.fasterxml.jackson.dataformat.yaml.YAMLParser.nextToken(YAMLParser.java:407)
at com.fasterxml.jackson.databind.deser.std.BaseNodeDeserializer._deserializeContainerNoRecursion(JsonNodeDeserializer.java:539)
at com.fasterxml.jackson.databind.deser.std.JsonNodeDeserializer.deserialize(JsonNodeDeserializer.java:98)
at com.fasterxml.jackson.databind.deser.std.JsonNodeDeserializer.deserialize(JsonNodeDeserializer.java:23)
at com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:323)
at com.fasterxml.jackson.databind.ObjectMapper._readTreeAndClose(ObjectMapper.java:4772)
at com.fasterxml.jackson.databind.ObjectMapper.readTree(ObjectMapper.java:3124)
at io.swagger.v3.parser.util.DeserializationUtils.readYamlTree(DeserializationUtils.java:232)
at io.swagger.v3.parser.util.DeserializationUtils.deserializeIntoTree(DeserializationUtils.java:143)
at io.swagger.v3.parser.OpenAPIV3Parser.readContents(OpenAPIV3Parser.java:168)
at io.swagger.v3.parser.OpenAPIV3Parser.readContents(OpenAPIV3Parser.java:107)
at io.swagger.parser.OpenAPIParser.readContents(OpenAPIParser.java:29)
at io.ballerina.openapi.core.GeneratorUtils.getOpenAPIFromOpenAPIV3Parser(GeneratorUtils.java:436)
at io.ballerina.openapi.core.GeneratorUtils.normalizeOpenAPI(GeneratorUtils.java:734)
at io.ballerina.openapi.cmd.BallerinaCodeGenerator.generateClientFiles(BallerinaCodeGenerator.java:333)
at io.ballerina.openapi.cmd.BallerinaCodeGenerator.generateClient(BallerinaCodeGenerator.java:215)
at io.ballerina.openapi.cmd.OpenApiCmd.generatesClientFile(OpenApiCmd.java:355)
at io.ballerina.openapi.cmd.OpenApiCmd.openApiToBallerina(OpenApiCmd.java:283)
at io.ballerina.openapi.cmd.OpenApiCmd.execute(OpenApiCmd.java:183)
at java.base/java.util.Optional.ifPresent(Optional.java:183)
at io.ballerina.cli.launcher.Main.main(Main.java:51)
Caused by: while scanning a double-quoted scalar
in 'reader', line 71, column 20:
pattern: "[a-zA-Z0-9,\\.\']"
^
found unknown escape character '(39)
in 'reader', line 71, column 36:
pattern: "[a-zA-Z0-9,\\.\']"
^
at org.yaml.snakeyaml.scanner.ScannerImpl.scanFlowScalarNonSpaces(ScannerImpl.java:1962)
at org.yaml.snakeyaml.scanner.ScannerImpl.scanFlowScalar(ScannerImpl.java:1895)
at org.yaml.snakeyaml.scanner.ScannerImpl.fetchFlowScalar(ScannerImpl.java:1075)
at org.yaml.snakeyaml.scanner.ScannerImpl.fetchDouble(ScannerImpl.java:1057)
at org.yaml.snakeyaml.scanner.ScannerImpl.fetchMoreTokens(ScannerImpl.java:445)
at org.yaml.snakeyaml.scanner.ScannerImpl.checkToken(ScannerImpl.java:256)
at org.yaml.snakeyaml.parser.ParserImpl$ParseBlockMappingValue.produce(ParserImpl.java:680)
at org.yaml.snakeyaml.parser.ParserImpl.peekEvent(ParserImpl.java:171)
at org.yaml.snakeyaml.parser.ParserImpl.getEvent(ParserImpl.java:181)
at com.fasterxml.jackson.dataformat.yaml.YAMLParser.nextToken(YAMLParser.java:403)
... 20 more
May 09, 2023 1:51:21 PM io.swagger.v3.parser.OpenAPIV3Parser readContents
WARNING: Exception while parsing:
com.fasterxml.jackson.dataformat.yaml.snakeyaml.error.MarkedYAMLException: while scanning a double-quoted scalar
in 'reader', line 71, column 20:
pattern: "[a-zA-Z0-9,\\.\']"
^
found unknown escape character '(39)
in 'reader', line 71, column 36:
pattern: "[a-zA-Z0-9,\\.\']"
^
at [Source: (StringReader); line: 71, column: 18]
at com.fasterxml.jackson.dataformat.yaml.snakeyaml.error.MarkedYAMLException.from(MarkedYAMLException.java:28)
at com.fasterxml.jackson.dataformat.yaml.YAMLParser.nextToken(YAMLParser.java:407)
at com.fasterxml.jackson.databind.deser.std.BaseNodeDeserializer._deserializeContainerNoRecursion(JsonNodeDeserializer.java:539)
at com.fasterxml.jackson.databind.deser.std.JsonNodeDeserializer.deserialize(JsonNodeDeserializer.java:98)
at com.fasterxml.jackson.databind.deser.std.JsonNodeDeserializer.deserialize(JsonNodeDeserializer.java:23)
at com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:323)
at com.fasterxml.jackson.databind.ObjectMapper._readTreeAndClose(ObjectMapper.java:4772)
at com.fasterxml.jackson.databind.ObjectMapper.readTree(ObjectMapper.java:3124)
at io.swagger.v3.parser.OpenAPIV3Parser.readContents(OpenAPIV3Parser.java:170)
at io.swagger.v3.parser.OpenAPIV3Parser.readContents(OpenAPIV3Parser.java:107)
at io.swagger.parser.OpenAPIParser.readContents(OpenAPIParser.java:29)
at io.ballerina.openapi.core.GeneratorUtils.getOpenAPIFromOpenAPIV3Parser(GeneratorUtils.java:436)
at io.ballerina.openapi.core.GeneratorUtils.normalizeOpenAPI(GeneratorUtils.java:734)
at io.ballerina.openapi.cmd.BallerinaCodeGenerator.generateClientFiles(BallerinaCodeGenerator.java:333)
at io.ballerina.openapi.cmd.BallerinaCodeGenerator.generateClient(BallerinaCodeGenerator.java:215)
at io.ballerina.openapi.cmd.OpenApiCmd.generatesClientFile(OpenApiCmd.java:355)
at io.ballerina.openapi.cmd.OpenApiCmd.openApiToBallerina(OpenApiCmd.java:283)
at io.ballerina.openapi.cmd.OpenApiCmd.execute(OpenApiCmd.java:183)
at java.base/java.util.Optional.ifPresent(Optional.java:183)
at io.ballerina.cli.launcher.Main.main(Main.java:51)
Caused by: while scanning a double-quoted scalar
in 'reader', line 71, column 20:
pattern: "[a-zA-Z0-9,\\.\']"
^
found unknown escape character '(39)
in 'reader', line 71, column 36:
pattern: "[a-zA-Z0-9,\\.\']"
^
at org.yaml.snakeyaml.scanner.ScannerImpl.scanFlowScalarNonSpaces(ScannerImpl.java:1962)
at org.yaml.snakeyaml.scanner.ScannerImpl.scanFlowScalar(ScannerImpl.java:1895)
at org.yaml.snakeyaml.scanner.ScannerImpl.fetchFlowScalar(ScannerImpl.java:1075)
at org.yaml.snakeyaml.scanner.ScannerImpl.fetchDouble(ScannerImpl.java:1057)
at org.yaml.snakeyaml.scanner.ScannerImpl.fetchMoreTokens(ScannerImpl.java:445)
at org.yaml.snakeyaml.scanner.ScannerImpl.checkToken(ScannerImpl.java:256)
at org.yaml.snakeyaml.parser.ParserImpl$ParseBlockMappingValue.produce(ParserImpl.java:680)
at org.yaml.snakeyaml.parser.ParserImpl.peekEvent(ParserImpl.java:171)
at org.yaml.snakeyaml.parser.ParserImpl.getEvent(ParserImpl.java:181)
at com.fasterxml.jackson.dataformat.yaml.YAMLParser.nextToken(YAMLParser.java:403)
... 18 more
May 09, 2023 1:51:21 PM io.swagger.parser.util.DeserializationUtils readYamlTree
WARNING: Error snake-parsing yaml content
io.swagger.parser.util.DeserializationUtils$SnakeException: Exception safe-checking yaml content (maxDepth 2000, maxYamlAliasesForCollections 2147483647)
at io.swagger.parser.util.DeserializationUtils$CustomSnakeYamlConstructor.getSingleData(DeserializationUtils.java:402)
at org.yaml.snakeyaml.Yaml.loadFromReader(Yaml.java:477)
at org.yaml.snakeyaml.Yaml.load(Yaml.java:406)
at io.swagger.parser.util.DeserializationUtils.readYamlTree(DeserializationUtils.java:220)
at io.swagger.parser.SwaggerParser.deserializeYaml(SwaggerParser.java:124)
at io.swagger.parser.SwaggerParser.readWithInfo(SwaggerParser.java:137)
at io.swagger.v3.parser.converter.SwaggerConverter.readContents(SwaggerConverter.java:97)
at io.swagger.parser.OpenAPIParser.readContents(OpenAPIParser.java:29)
at io.ballerina.openapi.core.GeneratorUtils.getOpenAPIFromOpenAPIV3Parser(GeneratorUtils.java:436)
at io.ballerina.openapi.core.GeneratorUtils.normalizeOpenAPI(GeneratorUtils.java:734)
at io.ballerina.openapi.cmd.BallerinaCodeGenerator.generateClientFiles(BallerinaCodeGenerator.java:333)
at io.ballerina.openapi.cmd.BallerinaCodeGenerator.generateClient(BallerinaCodeGenerator.java:215)
at io.ballerina.openapi.cmd.OpenApiCmd.generatesClientFile(OpenApiCmd.java:355)
at io.ballerina.openapi.cmd.OpenApiCmd.openApiToBallerina(OpenApiCmd.java:283)
at io.ballerina.openapi.cmd.OpenApiCmd.execute(OpenApiCmd.java:183)
at java.base/java.util.Optional.ifPresent(Optional.java:183)
at io.ballerina.cli.launcher.Main.main(Main.java:51)
Caused by: while scanning a double-quoted scalar
in 'string', line 71, column 20:
pattern: "[a-zA-Z0-9,\\.\']"
^
found unknown escape character '(39)
in 'string', line 71, column 36:
pattern: "[a-zA-Z0-9,\\.\']"
^
at org.yaml.snakeyaml.scanner.ScannerImpl.scanFlowScalarNonSpaces(ScannerImpl.java:1962)
at org.yaml.snakeyaml.scanner.ScannerImpl.scanFlowScalar(ScannerImpl.java:1895)
at org.yaml.snakeyaml.scanner.ScannerImpl.fetchFlowScalar(ScannerImpl.java:1075)
at org.yaml.snakeyaml.scanner.ScannerImpl.fetchDouble(ScannerImpl.java:1057)
at org.yaml.snakeyaml.scanner.ScannerImpl.fetchMoreTokens(ScannerImpl.java:445)
at org.yaml.snakeyaml.scanner.ScannerImpl.checkToken(ScannerImpl.java:256)
at org.yaml.snakeyaml.parser.ParserImpl$ParseBlockMappingValue.produce(ParserImpl.java:680)
at org.yaml.snakeyaml.parser.ParserImpl.peekEvent(ParserImpl.java:171)
at org.yaml.snakeyaml.comments.CommentEventsCollector$1.peek(CommentEventsCollector.java:57)
at org.yaml.snakeyaml.comments.CommentEventsCollector$1.peek(CommentEventsCollector.java:43)
at org.yaml.snakeyaml.comments.CommentEventsCollector.collectEvents(CommentEventsCollector.java:136)
at org.yaml.snakeyaml.comments.CommentEventsCollector.collectEvents(CommentEventsCollector.java:116)
at org.yaml.snakeyaml.composer.Composer.composeScalarNode(Composer.java:221)
at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:190)
at org.yaml.snakeyaml.composer.Composer.composeKeyNode(Composer.java:317)
at org.yaml.snakeyaml.composer.Composer.composeMappingChildren(Composer.java:308)
at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:293)
at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:194)
at org.yaml.snakeyaml.composer.Composer.composeValueNode(Composer.java:321)
at org.yaml.snakeyaml.composer.Composer.composeMappingChildren(Composer.java:312)
at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:293)
at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:194)
at org.yaml.snakeyaml.composer.Composer.composeValueNode(Composer.java:321)
at org.yaml.snakeyaml.composer.Composer.composeMappingChildren(Composer.java:312)
at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:293)
at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:194)
at org.yaml.snakeyaml.composer.Composer.composeValueNode(Composer.java:321)
at org.yaml.snakeyaml.composer.Composer.composeMappingChildren(Composer.java:312)
at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:293)
at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:194)
at org.yaml.snakeyaml.composer.Composer.composeValueNode(Composer.java:321)
at org.yaml.snakeyaml.composer.Composer.composeMappingChildren(Composer.java:312)
at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:293)
at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:194)
at org.yaml.snakeyaml.composer.Composer.composeValueNode(Composer.java:321)
at org.yaml.snakeyaml.composer.Composer.composeMappingChildren(Composer.java:312)
at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:293)
at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:194)
at org.yaml.snakeyaml.composer.Composer.getNode(Composer.java:116)
at org.yaml.snakeyaml.composer.Composer.getSingleNode(Composer.java:142)
at io.swagger.parser.util.DeserializationUtils$CustomSnakeYamlConstructor.getSingleData(DeserializationUtils.java:381)
... 16 more
OpenAPI definition has errors:
malformed or unreadable swagger supplied
attribute openapi is not of type `object`
This might be the same reason as here #1921 , at least the message Error snake-parsing yaml content is the same. I guess parsing failed also with snake-yml but it was successfully with jackson.
When using the swagger parser, we received the below log warning message[2] when we have a pattern regular value with syntax errors[1]. This error log is kind of confusing at a glance it looks like the tool was crashing. I wonder whether we can have any simple detailed error message for this instead of this warning.
Using
swaggerParserVersion=2.1.10
[1] openapi-spec
[2] Log warning