# Config.yaml multiline folding syntax

**URL:** <https://discuss.circleci.com/t/config-yaml-multiline-folding-syntax/25400>\
**Category:** Bug Reports\
**Created:** [September 26, 2018, 11:43am UTC](https://discuss.circleci.com/t/config-yaml-multiline-folding-syntax/25400 "2018-09-26T11:43:33Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ikerin](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/ikerin/32/19267_2.png) [@ikerin](https://discuss.circleci.com/u/ikerin)\
**Post date:** [September 26, 2018, 11:43am UTC](https://discuss.circleci.com/t/config-yaml-multiline-folding-syntax/25400/1 "2018-09-26T11:43:33Z")

</div>

```yaml
      - run: >
          curl https://shipit.ovotech.org.uk/deployments?apikey=$SHIPIT_API_KEY
            -d team=bit
            -d service=boost-bit-workflows
            -d buildId=$CIRCLE_BUILD_NUM
            -d "links[0].title=CircleCI build"
            -d "links[0].url=$CIRCLE_BUILD_URL"
            -d "links[1].title=Diff url"
            -d "links[1].url=$CIRCLE_COMPARE_URL"
            -d "notifySlackChannel=boost-bit-squad"

```

Results in this error message:

```bash
#!/bin/bash -eo pipefail
curl https://shipit.ovotech.org.uk/deployments?apikey=$SHIPIT_API_KEY
  -d team=bit
  -d service=boost-bit-workflows
  -d buildId=$CIRCLE_BUILD_NUM
  -d "links[0].title=CircleCI build"
  -d "links[0].url=$CIRCLE_BUILD_URL"
  -d "links[1].title=Diff url"
  -d "links[1].url=$CIRCLE_COMPARE_URL"
  -d "notifySlackChannel=boost-bit-squad"
/bin/bash: line 1: -d: command not found
Exited with code 127

```

But it should make it one line,

> <https://stackoverflow.com/questions/3790454/in-yaml-how-do-i-break-a-string-over-multiple-lines>

According to the 1.0 spec:  
[http://yaml.org/spec/1.0/#id2566944](http://yaml.org/spec/1.0/#id2566944)

---

<div class="post-metadata">

**Author:** ![halfer](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/halfer/32/9083_2.png) [@halfer](https://discuss.circleci.com/u/halfer)\
**Post date:** [September 26, 2018, 11:44am UTC](https://discuss.circleci.com/t/config-yaml-multiline-folding-syntax/25400/2 "2018-09-26T11:44:58Z")

</div>

The line breaks are still seen by the CLI. You need to append `\` to every non-last line.

---

<div class="post-metadata">

**Author:** ![marc](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/marc/32/835_2.png) [@marc](https://discuss.circleci.com/u/marc)\
**Post date:** [September 26, 2018, 12:11pm UTC](https://discuss.circleci.com/t/config-yaml-multiline-folding-syntax/25400/3 "2018-09-26T12:11:16Z")

</div>

```auto
$ pbpaste > config.yml
$ irb
irb(main):001:0> require 'yaml'
=> true
irb(main):008:0> print YAML.load(File.read('config.yml'))[0]['run']
curl https://shipit.ovotech.org.uk/deployments?apikey=$SHIPIT_API_KEY
  -d team=bit
  -d service=boost-bit-workflows
  -d buildId=$CIRCLE_BUILD_NUM
  -d "links[0].title=CircleCI build"
  -d "links[0].url=$CIRCLE_BUILD_URL"
  -d "links[1].title=Diff url"
  -d "links[1].url=$CIRCLE_COMPARE_URL"
  -d "notifySlackChannel=boost-bit-squad"=> nil
irb(main):009:0>

```

Ruby’s YAML parser behaves the same as the Java-based one that we are using internally.

I think it’s an indentation issue in the input string.

---

<div class="post-metadata">

**Author:** ![marc](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/marc/32/835_2.png) [@marc](https://discuss.circleci.com/u/marc)\
**Post date:** [September 26, 2018, 12:14pm UTC](https://discuss.circleci.com/t/config-yaml-multiline-folding-syntax/25400/4 "2018-09-26T12:14:36Z")

</div>

Oddly, if you indent the string like this is behaves you expect:

```auto
      - run: >
          curl https://shipit.ovotech.org.uk/deployments?apikey=$SHIPIT_API_KEY
          -d team=bit
          -d service=boost-bit-workflows
          -d buildId=$CIRCLE_BUILD_NUM
          -d "links[0].title=CircleCI build"
          -d "links[0].url=$CIRCLE_BUILD_URL"
          -d "links[1].title=Diff url"
          -d "links[1].url=$CIRCLE_COMPARE_URL"
          -d "notifySlackChannel=boost-bit-squad"

```

Yay for YAML 🙄

---

<div class="post-metadata">

**Author:** ![halfer](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/halfer/32/9083_2.png) [@halfer](https://discuss.circleci.com/u/halfer)\
**Post date:** [September 26, 2018, 12:50pm UTC](https://discuss.circleci.com/t/config-yaml-multiline-folding-syntax/25400/5 "2018-09-26T12:50:39Z")

</div>

Ooh, I didn’t know you could do that. Interesting!

Either way, use [this parser](http://yaml-online-parser.appspot.com/) to see how your file will be understood.

---

<div class="post-metadata">

**Author:** ![ikerin](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/ikerin/32/19267_2.png) [@ikerin](https://discuss.circleci.com/u/ikerin)\
**Post date:** [September 26, 2018, 2:36pm UTC](https://discuss.circleci.com/t/config-yaml-multiline-folding-syntax/25400/6 "2018-09-26T14:36:00Z")

</div>

Wow! That was a speedy reply 10x a lot guys. What parser is actually used by circleci? I thought I’ve seen Clojure errors so I assumed it was that, but I guess its probably just a Java lib.

---

<div class="post-metadata">

**Author:** ![ulidtko](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/ulidtko/32/21578_2.png) [@ulidtko](https://discuss.circleci.com/u/ulidtko)\
**Post date:** [November 16, 2020, 6:04pm UTC](https://discuss.circleci.com/t/config-yaml-multiline-folding-syntax/25400/7 "2020-11-16T18:04:53Z")

</div>

This does seem as correctly meeting YAML 1.0 specification. Not a bug.

Notice the indents:

```auto
test: >
  foo
  --bar
  --buzz

```

— gives `{ "test": "foo --bar --buzz\n" }` as expected, **but**

```auto
test: >
  foo
    --bar
    --buzz

```

— gives `{ "test": "foo\n --bar\n --buzz\n" }`.

This is correct on the grounds of [4.6.6.1](https://yaml.org/spec/1.0/#id2566944), emphasis mine:

> The combined effect of the processing rules above is that each “paragraph” is interpreted as a single line, empty lines are used to represent a line feed, **and “more indented” lines are preserved**.

Also see Example 4.24 where the spec gives understandable motivation behind this:

```yaml
indented text: >
    This is a folded paragraph
    followed by a list:
     * first entry
     * second entry
    Followed by [...]

above is equal to: |
    This is a folded paragraph followed by a list:
     * first entry
     * second entry
    Followed by [...]

```

* * *

**TL;DR** you must not indent subsequent lines in a folded block scalar. This would work as you expect:

```yaml
     - run: >
          curl https://shipit.ovotech.org.uk/deployments?apikey=$SHIPIT_API_KEY
          -d team=bit
          -d service=boost-bit-workflows
          -d buildId=$CIRCLE_BUILD_NUM

```

or this (using literal block scalar and `bash`-level line continuations):

```yaml
     - run: |
          curl https://shipit.ovotech.org.uk/deployments?apikey=$SHIPIT_API_KEY \
            -d team=bit \
            -d service=boost-bit-workflows \
            -d buildId=$CIRCLE_BUILD_NUM \
            [...]

```
