I’m working with the YamlDotNet library and I’m getting this error when loading a YAML file:
While parsing a tag, did not find expected tag URI.
The YAML file is supposed to be well-formed because it comes right from RoR. The error seems to be triggered by this code:
formats:
default: ! '%d-%m-%Y'
long: ! '%d %B, %Y'
short: ! '%d %b'
I’m not an expert, but I see from the YAML spec that you can use an exclamation mark to indicate a custom object/type, and two exclamation marks to indicate an explicit built-in type.
obj1: !custom # whatever
obj2: !!str "My string"
However I haven’t been able to find any reference to an exclamation mark used as above. What does that mean, and why the YAML library I use doesn’t seem able to parse it? Note that if I remove those exclamation marks, the file is parsed fine.
That
!is the non-specific tag.The YAML specification 1.2 (as well as the previous 1.1) says that :
Take a look here to the tag "grammar":
Why is YamlDotNet throwing a error? I can’t be 100% sure, but I think you found a bug.
YamlDotNet is a port of LibYAML, so it’s easy to compare sources.
Line 2635 of scanner.c (LibYAML):
Line 2146 of Scanner.cs (YamlDotNet ):
I know, both looks very similar, but at this point
lengthis 1 andtag.Lengthis 0. Original C code takes care of the initial "!" (whole length) but C# doesn’t do it (just the tag "name" length).File an issue to the project.