Errors with some characters in multi-line body strings
nwhittaker opened this issue · comments
Passing a multi-line body
sometimes produces an error depending on the contents of the string. Here are a few of the errors I've encountered:
Asterisks
body: |
*TODO*
produces
::error::unidentified alias "TODO*" (1:7)
1 | *TODO*
----------^
Colon
body: |
message
TODO:
produces
::error::end of the stream or a document separator is expected (2:5)
1 | Message
2 | TODO:
---------^
One workaround is to double-pipe the body as mentioned in #6 (comment).
body: |
|
...
I think we could change the behavior of how the YAML strings are parsed in this line
Line 61 in 5c012a1
if value.trim()
starts with |\s*\n
, we could bypass yaml.load(value)
. What do you think?
if value.trim() starts with
|\s*\n
, we could bypassyaml.load(value)
. What do you think?
I think that sounds reasonable. Are you basically just forgoing yaml.load()
if the value is a block scalar? How about if the string includes a block header (e.g. |+2
), or uses the folded style (>
) instead?
Are you basically just forgoing
yaml.load()
if the value is a block scalar
yes, that's the idea
How about if the string includes a block header (e.g.
|+2
), or uses the folded style (>
) instead?
🤷🏼 this might get pretty complex pretty quick, hm? I don't know what the best approach could be. Maybe for the time being we should at least document the workaround using two |
?
🤷🏼 this might get pretty complex pretty quick, hm? I don't know what the best approach could be.
Agreed -- I don't have too much experience with yaml, but maybe there's a yaml library that can report the data type for a value?
Maybe for the time being we should at least document the workaround using two |?
Sounds good to me.
Maybe for the time being we should at least document the workaround using two |?
Sounds good to me.
could you send a PR? I can do it myself, eventually, but would appreciate the help
Added #81. Not sure if I totally understand why the behavior is the way it is, or what exactly the intended happy-path is with regards to property values (json or yaml?), but I think these examples should help with getting things working.
resolved with #81