Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors with some characters in multi-line body strings #79

Closed
nwhittaker opened this issue Feb 22, 2021 · 7 comments
Closed

Errors with some characters in multi-line body strings #79

nwhittaker opened this issue Feb 22, 2021 · 7 comments
Labels
Type: Documentation Improvements or additions to documentation

Comments

@nwhittaker
Copy link
Contributor

nwhittaker commented Feb 22, 2021

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: |
  |
  ...
@gr2m
Copy link
Contributor

gr2m commented Feb 22, 2021

I think we could change the behavior of how the YAML strings are parsed in this line

result[inputName] = yaml.load(value);

if value.trim() starts with |\s*\n, we could bypass yaml.load(value). What do you think?

@nwhittaker
Copy link
Contributor Author

if value.trim() starts with |\s*\n, we could bypass yaml.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?

@gr2m
Copy link
Contributor

gr2m commented Feb 22, 2021

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 |?

@nwhittaker
Copy link
Contributor Author

🤷🏼 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.

@gr2m
Copy link
Contributor

gr2m commented Feb 23, 2021

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

@nwhittaker
Copy link
Contributor Author

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.

@gr2m
Copy link
Contributor

gr2m commented Mar 1, 2021

resolved with #81

@gr2m gr2m closed this as completed Mar 1, 2021
@gr2m gr2m added bug Type: Documentation Improvements or additions to documentation labels Mar 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants