# YAML parser confused by colons in shell commands

**URL:** <https://discuss.circleci.com/t/yaml-parser-confused-by-colons-in-shell-commands/2077>\
**Category:** Bug Reports\
**Tags:** circle-yml\
**Created:** [February 11, 2016, 10:03pm UTC](https://discuss.circleci.com/t/yaml-parser-confused-by-colons-in-shell-commands/2077 "2016-02-11T22:03:30Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![mboes](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/mboes/32/387_2.png) [@mboes](https://discuss.circleci.com/u/mboes)\
**Post date:** [February 11, 2016, 10:03pm UTC](https://discuss.circleci.com/t/yaml-parser-confused-by-colons-in-shell-commands/2077/1 "2016-02-11T22:03:31Z")

</div>

The following snippet doesn’t parse as expected:

```
dependencies:
  override:
   - echo 'extra-include-dirs: [foo, bar]' > config.yaml

```

The issue is that your parser thinks that “echo 'extra-include-dirs” is the name of a key in a map. In this particular case, it turns out removing the space between the “:” character and the “[” above is a workaround to this particular parser bug.

---

<div class="post-metadata">

**Author:** ![frank](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/frank/32/124_2.png) [@frank](https://discuss.circleci.com/u/frank)\
**Post date:** [February 11, 2016, 11:21pm UTC](https://discuss.circleci.com/t/yaml-parser-confused-by-colons-in-shell-commands/2077/2 "2016-02-11T23:21:04Z")

</div>

Hi @mboes,

I don’t believe this is a bug with our parser as it’s just the nature of how YAML works in general by recognizing a colon and a space as a key-value separator. You should be able to work around this by making your circle.yml look like this instead:

```auto
dependencies:
  override:
   - |
     echo 'extra-include-dirs: [foo, bar]' > config.yaml

```

For more information, see “2.3 Scalars” in the [YAML spec](http://www.yaml.org/spec/1.2/spec.html), or try your YAML out at [http://www.yamllint.com/](http://www.yamllint.com/).

Cheers,  
Frank

---

<div class="post-metadata">

**Author:** ![dennybaa](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/dennybaa/32/406_2.png) [@dennybaa](https://discuss.circleci.com/u/dennybaa)\
**Post date:** [February 13, 2016, 7:41am UTC](https://discuss.circleci.com/t/yaml-parser-confused-by-colons-in-shell-commands/2077/3 "2016-02-13T07:41:57Z")

</div>

Hi folks, @frank, @mboes!

I’m facing the same issue, yaml parsing since to be broken. I also believe it’s a bug!

```auto
--- 
dependencies: 
  cache_directories: 
    - ~/.cache/pip
  override: 
    - 
      ? | 
        docker pull stackstorm/buildpack:centos7

```

This is not just useless complex key, which produces error:

```auto
Action failed: Configure the build
modifiers to 'buildpack:centos7' must be a map

Action failed: Configure the build

```

But it’s a feature which I’m using to run commands in parallel by help of small wrapper bash function which I called step. So the following test code works like charm without all extra pollution [$CIRCLE\_NODE\_INDEX = smth] etc, all the logic to fire action on a specific node is wrapped. Yaml at the same time stays clean, but fully descriptive:

```auto
test:
  override:
    - ? |
        step tox -e lint; next
        step tox -e py27
      : parallel: true

```

All the above examples are absolutely valid yamls, you can check on it in [www.yamllint.com](http://www.yamllint.com)! While test example works and doesn’t produce any error, dependency stage with docker pull command fails, exactly because of parse failure broken and can’t parse line containing `:`.

– Denis

---

<div class="post-metadata">

**Author:** ![frank](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/frank/32/124_2.png) [@frank](https://discuss.circleci.com/u/frank)\
**Post date:** [February 16, 2016, 3:12pm UTC](https://discuss.circleci.com/t/yaml-parser-confused-by-colons-in-shell-commands/2077/4 "2016-02-16T15:12:13Z")

</div>

The complex key identifier `?` uses a colon to know when the complex key has ended.

In the `docker pull` example you showed above, there is no need to use both a complex key identifier and a scalar identifier. The scalar by itself should suffice. It should look something like this:

```auto
dependencies: 
  cache_directories: 
    - ~/.cache/pip
  override: 
    - | 
      docker pull stackstorm/buildpack:centos7

```

-Frank

---

<div class="post-metadata">

**Author:** ![dennybaa](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/dennybaa/32/406_2.png) [@dennybaa](https://discuss.circleci.com/u/dennybaa)\
**Post date:** [February 16, 2016, 4:20pm UTC](https://discuss.circleci.com/t/yaml-parser-confused-by-colons-in-shell-commands/2077/5 "2016-02-16T16:20:11Z")

</div>

Yup @frank, I agree.

That’s indeed sufficient, however the following form is valid according to yamllint

```auto
--- 
dependencies: 
  cache_directories: 
    - ~/.cache/pip
  override: 
    - 
      ? "docker pull stackstorm/buildpack:centos7"
      : ~

```

And it couldn’t be parsed correctly by cicrcle yaml parser, I don’t think it’s a matter of high importance, but nevertheless parsing fails. It’s probably caused due to that parser expects only modifiers hash, but actually there could be `: ~` also. Anyway, it doesn’t correlate with the original matter of the issue, where just simply incorrect syntax has been provided. 🙂

---

<div class="post-metadata">

**Author:** ![cvermilion](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/cvermilion/32/136_2.png) [@cvermilion](https://discuss.circleci.com/u/cvermilion)\
**Post date:** [January 16, 2018, 7:26pm UTC](https://discuss.circleci.com/t/yaml-parser-confused-by-colons-in-shell-commands/2077/6 "2018-01-16T19:26:55Z")

</div>

Just hit myself, and I also think this is a bug in the YAML parsing. According to the [spec](http://www.yaml.org/spec/1.2/spec.html#style/flow/double-quoted) you can put anything but control characters, backslashes, and double quotes inside double-quoted string scalars.

[http://www.yamllint.com/](http://www.yamllint.com/) is also quite happy with

```auto
--- 
foo: "bar: baz"

```

(whereas dropping the quotes produces an error)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/circleci/original/3X/5/1/511608acda8e85906e15909b57bd0a46c1dbe291.png) [@system](https://discuss.circleci.com/u/system)\
**Post date:** [June 18, 2018, 11:33am UTC](https://discuss.circleci.com/t/yaml-parser-confused-by-colons-in-shell-commands/2077/7 "2018-06-18T11:33:58Z")

</div>


