carvel-dev / carvel-dev/ytt

Appending a Document to an empty Document Set panics

Open
#548 1 comment 1 reaction 0 assignees View on GitHub
bug priority/unprioritized-backlog
Dominant language
Go
Stars
1.9k
Forks
167
PR merge metrics
No merged PRs in 30d

Description

**What steps did you take:**

With this input (i.e. an overlay that appends a document):

```
#@overlay/match by=lambda: False
#@overlay/append
---
kind: Stuff
```

ran:

```bash
$ ytt -f .
```

**What happened:**

```bash
panic: runtime error: index out of range [-1]

goroutine 1 [running]:
github.com/k14s/ytt/pkg/yttlibrary/overlay.Op.appendDocument(...)
github.com/k14s/ytt/pkg/yttlibrary/overlay/document.go:195
github.com/k14s/ytt/pkg/yttlibrary/overlay.Op.applyDocSet({{0x1469760, 0xc00000cb70}, {0x14f1640, 0xc0001a8cb0}, 0xc0001ea9b0, 0x0}, {0x1993b70, 0x1a7c101, 0x0}, 0xc0001a8cb0, ...)
github.com/k14s/ytt/pkg/yttlibrary/overlay/op.go:155 +0x805
github.com/k14s/ytt/pkg/yttlibrary/overlay.Op.apply({{0x1469760, 0xc00000cb70}, {0x14f1640, 0xc0001a8cb0}, 0xc0001ea9b0, 0x0}, {0x1469760, 0xc00000cb88}, {0x14f1640, 0xc0001a8cb0}, ...)
github.com/k14s/ytt/pkg/yttlibrary/overlay/op.go:55 +0x328
github.com/k14s/ytt/pkg/yttlibrary/overlay.Op.Apply({{0x1469760, 0xc00000cb70}, {0x14f1640, 0xc0001a8cb0}, 0xc0001ea9b0, 0x0})
github.com/k14s/ytt/pkg/yttlibrary/overlay/op.go:27 +0x14f
github.com/k14s/ytt/pkg/workspace.OverlayPostProcessing.Apply({0xc000141a48})
github.com/k14s/ytt/pkg/workspace/overlay_post_processing.go:63 +0x716
github.com/k14s/ytt/pkg/workspace.(*LibraryExecution).Eval(0xc000141a48, 0x0, {0x0, 0x0, 0x1659478}, {0x0, 0xc00007d960, 0x0})
github.com/k14s/ytt/pkg/workspace/library_execution.go:191 +0x7b
github.com/k14s/ytt/pkg/cmd/template.(*Options).RunWithFiles(0xc00015e580, {{0xc00000e108, 0x2, 0x100c000141ae0}}, {0x165e748, 0xc0001a3380})
github.com/k14s/ytt/pkg/cmd/template/cmd.go:158 +0x567
github.com/k14s/ytt/pkg/cmd/template.(*Options).Run(0xc00015e580)
github.com/k14s/ytt/pkg/cmd/template/cmd.go:97 +0x4b1
github.com/k14s/ytt/pkg/cmd/template.NewCmd.func1(0x1359b85, {0xc00007e9a0, 0x0, 0x0})
github.com/k14s/ytt/pkg/cmd/template/cmd.go:62 +0x1d
github.com/cppforlife/cobrautil.WrapRunEForCmd.func1.1(0xc00017c600, {0xc00007e9a0, 0x0, 0x2})
github.com/cppforlife/cobrautil@v0.0.0-20200514214827-bb86e6965d72/misc.go:45 +0x6d
github.com/cppforlife/cobrautil.WrapRunEForCmd.func1.1(0xc000190a00, {0xc00007e9a0, 0x0, 0x2})
github.com/cppforlife/cobrautil@v0.0.0-20200514214827-bb86e6965d72/misc.go:45 +0x6d
github.com/spf13/cobra.(*Command).execute(0xc000190a00, {0xc00001e1c0, 0x2, 0x2})
github.com/spf13/cobra@v1.2.1/command.go:856 +0x60e
github.com/spf13/cobra.(*Command).ExecuteC(0xc000190a00)
github.com/spf13/cobra@v1.2.1/command.go:974 +0x3bc
github.com/spf13/cobra.(*Command).Execute(...)
github.com/spf13/cobra@v1.2.1/command.go:902
main.main()
github.com/k14s/ytt/cmd/ytt/ytt.go:21 +0xd6
```

**What did you expect:**
The document to be appended to the empty DocumentSet.

**Anything else you would like to add:**

Slack thread: https://kubernetes.slack.com/archives/CH8KCCKA5/p1637354198458400?thread_ts=1637349049.448900&cid=CH8KCCKA5

**Environment:**

- ytt version (use `ytt --version`): v0.38.0

---
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.