bitrise-workflow-editor icon indicating copy to clipboard operation
bitrise-workflow-editor copied to clipboard

Newline characters changed to \n in bitrise.yml view

Open koral-- opened this issue 7 years ago • 13 comments

I have a workflow with 2 script steps. One of them looks consistently in both Workflows and bitrise.yml tabs but 2nd one has newline characters replaced with \n. image image

Step have been added and edited using Workflows tab only. Content in that tab is the proper one.

koral-- avatar Jun 21 '17 00:06 koral--

Hi @koral--

This is unfortunately a bit out of our control. Both representations are correct from a YML spec perspective, and so it depends on the serializer how it serializes that string content.

Added the wontfix label as we probably won't have enough time to dig into the go yaml lib (https://github.com/go-yaml/yaml), but of course contributions / PRs are always welcome!

viktorbenei avatar Jun 21 '17 09:06 viktorbenei

Isn't it possible to just force particular style when content is modified in Workflow tab? E.g. use multiline block beginning with |-.

koral-- avatar Jun 21 '17 09:06 koral--

If you find an option in the docs (http://godoc.org/gopkg.in/yaml.v2 / https://github.com/go-yaml/yaml) please let us know! ;)

viktorbenei avatar Jun 21 '17 10:06 viktorbenei

I guess PR should go there. Even if such will be made that lib does not seem to be contributor friendly: several dozens of issues and PRs opened for months and this: https://github.com/go-yaml/yaml/issues/261

koral-- avatar Jun 21 '17 10:06 koral--

It's quite a stable lib, we never had any issue with it, that might explain the lack of activity there, but of course there's always room for improvement.. To be honest this is like the de factor Go standard YAML lib, switching to any other would be quite a risk

viktorbenei avatar Jun 21 '17 10:06 viktorbenei

I've managed to determine the scenario in which content is "squashed". It happens when there is a chain of whitespaces at the end of an input beginning with space character. For example: one space, space + newline etc. It does not happen when there are newlines only.

I guess that if there are only spaces a the end, text may be intentionally enclosed with double quotes to preserve it and this is only valid solution.

However, if there are spaces followed by newlines both block and quoted text can be used. Right?

koral-- avatar Jun 21 '17 12:06 koral--

I guess that if there are only spaces a the end, text may be intentionally enclosed with double quotes to preserve it and this is only valid solution.

That would make sense. Technically it'd be possible to keep the line ending spaces in the non double quoted form I believe, but the double quoted form is definitely more reliable / less error prone as a serialized form.

However, if there are spaces followed by newlines both block and quoted text can be used. Right?

I think technically that should be possible.

viktorbenei avatar Jun 21 '17 18:06 viktorbenei

I've just checked case when trailing sequence of whitespaces contains spaces between newlines and quotes were also used.

So, to sum up, it seems that the only feasible action for this is to fill an issue on https://github.com/go-yaml/yaml asking them to prefer block notation if text ends with newline character or in other words use quotes only if space is at the end but not in any position of trailing whitespace sequence.

koral-- avatar Jun 21 '17 18:06 koral--

So, to sum up, it seems that the only feasible action for this is to fill an issue on https://github.com/go-yaml/yaml

Indeed. I believe we tried to find another YAML lib for Go initially when we saw this same issue, but did not find any suitable alternative.

viktorbenei avatar Jun 22 '17 10:06 viktorbenei

@koral-- are you still facing the issue?

doomsayer13 avatar Sep 18 '18 14:09 doomsayer13

Yep, just checked and it is still present. Moreover, it seems that now text is a single, quoted line always if there is any whitespace at the end including single newline.

koral-- avatar Sep 18 '18 15:09 koral--

This is still an issue and super-annoying. Unfortunately, Bitrise seems to have many of these little bugs (also UI/UX issues) that might cause our company to choose another option.

jbweimar avatar Jun 25 '20 19:06 jbweimar

Workaround: Just avoid having a space at the end of any line.

paramaggarwal avatar Apr 18 '21 00:04 paramaggarwal