Skip to content
configkit

Found character that cannot start any token

The parser hit a character that YAML does not allow at that position. It is almost always a tab used for indentation. The other cause is a value that starts with a reserved character.

The message

kubectl and Helm print yaml: line 2: found character that cannot start any token. PyYAML prints found character '\t' that cannot start any token, where \t is the tab. ConfigKit names the cause directly: Tabs are not allowed as indentation, with the line and column.

Cause 1: a tab as indentation

The second line below starts with a tab character. It looks the same as spaces in most editors.

service:
	port: 8080

YAML indentation must be spaces. Replace the tab with two spaces. Tabs usually arrive by copying from a web page, a Makefile, or an editor set to indent with tabs. To stop it happening again, add this to .editorconfig at the root of the repository:

[*.{yml,yaml}]
indent_style = space
indent_size = 2

Cause 2: a reserved first character

@ and the backtick are reserved in YAML. An unquoted value cannot start with either one.

user: @admin
cmd: `ls`

ConfigKit reports Plain value cannot start with reserved character @ at line 1, column 7. Quote the value: user: "@admin" becomes the JSON string "@admin".

The edge case

A tab inside a quoted string is part of the value and is allowed. a: "x\ty" converts to {"a": "x\ty"}. Only tabs at the start of a line, used to indent, are rejected.

The YAML validator points at the first tab. For a manifest with several documents, use the Kubernetes YAML check.