-
Notifications
You must be signed in to change notification settings - Fork 136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Panics when appending to "empty" #718
Comments
This is absolutely a bug. From the docs:
|
@mamachanko a workaround: #! dreams.yaml
#@ load("@ytt:overlay", "overlay")
--- _
#@overlay/match by=overlay.subset("_")
#@overlay/replace
---
name: Matthew
profession: Raven |
While trying to write a template test for this, I realised that I can't reproduce it with a #! pkg/yamltemplate/filetests/ytt-library/overlay/append-to-nothing.tpltest
#@ load("@ytt:overlay", "overlay")
#@overlay/match by=overlay.subset({"name": "Sandman", "profession": "King of Dreams"})
#@overlay/append
---
name: Matthew
profession: Raven
+++
---
First I thought it maybe already fixed on
So I think the template tests don't fully replicate Either way, from what I can tell, this is the offending line as per trace and studying the code. I think it would make sense to append nothing if there are no left-hand docs. The same probably goes for arrays. |
Yes... so the defect here is happening across DocSets.. and the In the case with the unit tests, we're supplying the "YAML file" (i.e. the top-half of that test fixture) and we're testing below the layer of code that combines all the DocSets together.
bingo.
🤔 Can you elaborate, there? I'm concerned we've had a potential blindspot, here... so unpacking this would be very useful. To date, in the array case, we are appending. The docs are describing what the to-date intended behavior to be: https://carvel.dev/ytt/docs/v0.42.0/lang-ref-ytt-overlay/#overlayappend An the software matches the documentation in the array item case; just not for the document case. stuffs: []
#@overlay/match by=lambda i,l,r: True
---
stuffs:
- 3 yields: stuffs:
- 3 ... further, if we were going to be strictly consistent, then |
I was thinking that, when the match is empty, i.e. there are is no left-hand side, then nothing should be appended. But now I am not sure any more either. DocSets and []DocsSets are - in a way, or precisely - arrays of docs. The root of
Yields:
That's consistent with the idea of always being able to append to the array of documents, even if you don't match. I think it's getting esoteric. 😆 But by extension, then #@ load("@ytt:overlay", "overlay")
#! v--v
#@overlay/match by=lambda i,l,r: True, expects="0+"
#@overlay/append
---
appended doc
#! v---v
#@overlay/match by=lambda i,l,r: False, expects="0+"
#@overlay/append
---
appended doc should yield: appended doc
---
appended doc Or should it not? |
Erroneously closed (an ill-worded comment triggered the workflow in GitHub) |
This issue is being marked as stale due to a long period of inactivity and will be closed in 5 days if there is no response. |
This issue is being marked as stale due to a long period of inactivity and will be closed in 5 days if there is no response. |
Looks like this issue was already closed as completed on Nov 17, 2022. Closing it again. |
What steps did you take:
What happened:
What did you expect:
A helpful error message.
Anything else you would like to add:
[Additional information that will assist in solving the issue.]
Environment:
ytt --version
):ytt version 0.42.0
/etc/os-release
): macOSVote 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.
The text was updated successfully, but these errors were encountered: