Overlaying list on schema renders incorrectly
- Dominant language
- Go
- Stars
- 1.9k
- Forks
- 167
- PR merge metrics
- No merged PRs in 30d
Description
**What steps did you take:**
I expect b.yaml to append item "var1" to *vars* list in each app. However the item is appended twice (or more depending on how many items are in apps).
schema.yaml
```yaml
#@data/values-schema
---
apps:
- name: ""
vars:
- ""
```
a.yaml
```yaml
#@data/values
---
apps:
- name: app1
- name: app2
```
b.yaml
```yaml
#@data/values
#@ load("@ytt:overlay", "overlay")
---
apps:
#@overlay/match by=overlay.all, expects="1+"
- vars:
- var1
```
```shell
ytt -f schema.yaml -f a.yaml -f b.yaml --data-values-inspect
```
**What happened:**
"var1" is appended to each *vars* list twice.
```yaml
apps:
- name: app1
vars:
- var1
- var1
- name: app2
vars:
- var1
- var1
```
**What did you expect:**
"var1" appended once to *vars* list.
```yaml
apps:
- name: app1
vars:
- var1
- name: app2
vars:
- var1
```
**Anything else you would like to add:**
Setting *vars* to an empty list in a.yaml explicitly resolves this issue, however it's not the same semantically (default value from schema file gets lost).
```yaml
#@data/values
---
apps:
- name: app1
vars: []
- name: app2
```
Additionally, defining b.yaml as following to only match on name=app1, appends item to every list item (behaving like overlay.all).
```yaml
#@data/values
#@ load("@ytt:overlay", "overlay")
---
apps:
#@overlay/match by=overlay.map_key("name"), expects="1+"
- name: app1
vars:
- var1
```
**Environment:**
- ytt version (use `ytt --version`):
ytt version 0.49.0
- OS (e.g. from `/etc/os-release`):
macOS 14.4.1 M1
---
Vote on this request
This is an invitation to the community to vote on issues, to help us prioritize our backlog. Use the "smiley face" up to the right of this comment to vote.
👍 "I would like to see this addressed as soon as possible"
👎 "There are other more important things to focus on right now"
We are also happy to receive and review Pull Requests if you want to help working on this issue.
Contributor guide
Research direction
Reproduce the issue with schema.yaml, a.yaml, and b.yaml using `ytt -f schema.yaml -f a.yaml -f b.yaml --data-values-inspect` on ytt 0.49.0. Compare overlay.all and overlay.map_key("name") behavior with and without an explicit empty vars list; done means each app receives var1 exactly once while preserving the schema default.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, yaml
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100