What the error means
YAML has two ways to write a list or a mapping. The block style uses indentation and dashes; the flow style uses JSON-like brackets and braces on a single line: [a, b] or {key: value}. A flow collection must be closed. When the parser opens one and reaches the end of the input without finding the matching ] or }, it reports unexpected end of the stream within a flow collection.
The phrase "end of the stream" is why this error is confusing: it is reported at the last line of the file, however far that is from the actual mistake. In the example, the missing ] is on line one, but the parser happily consumes owner: platform as more list content and only fails when the input runs out.
Why it happens
- A dropped closing bracket after editing a list inline, typically when an item is added at the end.
- A line break inside a flow collection. Flow style can span lines, but a following line that looks like a mapping key is swallowed as list content, so the collection never closes where you expect.
- Mixing styles: starting a list with
[and then continuing with- itemlines on the next lines. - A quote mismatch inside the brackets, so the closing bracket is read as part of a string.
How to fix it
- Paste the document into the converter above. Ignore the reported line; instead, search the file for
[and{and check that each has a closer on the same line. - Add the missing
]or}. In the example, line one becomestags: [api, internal]. - Convert again. The JSON output shows the list as an array, which confirms the collection closed where you intended and that
owneris a sibling key, not a list item.
The corrected example:
tags: [api, internal]
owner: platform
For a long list, block style is easier to keep balanced:
tags:
- api
- internal
owner: platform
If it still fails
- Check for an unmatched quote inside the collection.
[api, "internal]never closes the string, so the bracket after it is part of the value. - If the file is a Kubernetes manifest or a Compose file produced by a template, search the template for the bracket rather than the output.
- The same underlying problem in JSON produces
Unexpected end of JSON input; the fix is the same, and JSON Validator reports the structure it read before the input ran out.
Related errors
Unexpected end of JSON input
The document ends early. Close every open brace and bracket, or check that the string you are parsing is not empty or truncated before it reaches JSON.parse.
bad indentation of a mapping entry
Every key in the same mapping must start in the same column, indented with spaces only. Align the offending line with its siblings and replace any tab with spaces.