When a document literal is conditionally removed and there is subsequent content, the resulting program attempts to build an invalid YAML document
- Dominant language
- Go
- Stars
- 1.9k
- Forks
- 167
- PR merge metrics
- No merged PRs in 30d
Description
When:
1. a YAML document is annotated with `ytt` flow control
1. that flow control encapsulates a document start
1. that flow control evaluates such that the compiled template does not insert the document node
1. one or more Map or Array Items appear after the `end` of the flow control (and there is no intervening document)
Then:
- the template is compiled to a Starlark program where a `start_node()` of the Map/Array Item appears directly after the `start_node()` of the DocSet: an invalid YAML document
- the error presented to the user presents internal details without marking them as such.
For example, with this:
`foo.yml`
```yaml
#@ def func():
---
#@ end
a: 1
```
or
```yaml
#@ if False:
---
#@ end
a: 1
```
and `ytt -f foo.yml` yields this:
```
ytt: Error:
- __ytt_tpl2_start_node: cannot add non-document value (*yamlmeta.MapItem) into documentset
in
foo.yml:4 | a: 1
```
This is a request to:
1. Find a way to present this error message such that either a) the end-user has the right information to solve the problem; or b) make clear that an internal error has occurred and this should be reported as a bug.
1. Adjust the parsing/compilation of templates so that inputs like `foo.yml` result in a valid YAML document.
Contributor guide
Research direction
Start with the foo.yml examples and run ytt -f foo.yml to reproduce the invalid document and exposed internal error. Trace the parsing and compilation path for conditional document starts and subsequent Map or Array Items; done means the input produces a valid YAML document and the error gives actionable user guidance or clearly identifies an internal bug.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- cli, compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100