Skip to content
configkit

Mapping values are not allowed here

The parser found a colon followed by a space where it did not expect a new key. Either a value contains ': ', or a key is indented under something that cannot hold one.

The message

Each parser words it differently. Python's PyYAML says mapping values are not allowed here. Go tools such as kubectl and Helm say mapping values are not allowed in this context. ConfigKit says Nested mappings are not allowed in compact mappings and points at the column.

Cause 1: a colon inside a value

A colon followed by a space starts a key. Inside an unquoted value, the parser reads key as a second key on the same line.

command: echo key: value

ConfigKit reports line 1, column 10. Quote the whole value. The JSON is then {"command": "echo key: value"}.

command: "echo key: value"

The same happens with commit messages, log lines, and help text that contain a colon. Single quotes work too. Inside single quotes, write a literal ' as ''.

Cause 2: a key indented too far

labels is indented one space more than name, so the parser reads it as part of the value web.

metadata:
  name: web
   labels: x

Line every key in a mapping up at the same column. When a key is indented one space less than its siblings instead, ConfigKit reports All mapping items must start at the same column.

The edge case

A colon with no space after it does not start a key. These are plain strings and need no quotes:

url: http://example.com:8080/x
time: 12:30

ConfigKit reads YAML 1.2, where 12:30 is the string "12:30". Some older YAML 1.1 parsers read it as the number 750 (12 × 60 + 30). Quote times if another program will read the same file.

Paste the file into the YAML validator to find the column, or into YAML to JSON to see what each value becomes.