chainguard-dev / terraform-provider-apko

https://registry.terraform.io/providers/chainguard-dev/apko/latest
Mozilla Public License 2.0
14 stars 13 forks source link

I probably have invalid config, but it manages to crash apko #326

Open xnox opened 3 months ago

xnox commented 3 months ago
│ Error: Invalid index
│ 
│   on tflib/versions/main.tf line 100, in locals:
│  100:   versions_no_latest = merge({ for k, v in local.eol_versions : k => v if timecmp(timeadd("${v["eolDate"]}T00:00:00Z", "${local.eol_grace_hours}h"), local.now) >= 0 }, local.active_versions)
│ 
│ The given key does not identify an element in this collection value.
╵

Stack trace from the terraform-provider-apko_v0.15.12 plugin:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x472dee]

goroutine 35987 [running]:
chainguard.dev/apko/pkg/tarfs.(*memFile).Write(0xc028c2d440, {0xc007296000?, 0x320, 0x0?})
    chainguard.dev/apko@v0.14.8/pkg/tarfs/fs.go:924 +0x195
bytes.(*Buffer).WriteTo(0xc0158c2d80, {0x7c6d6e621958?, 0xc028c2d440?})
    bytes/buffer.go:261 +0x7b
io.copyBuffer({0x7c6d6e621958, 0xc028c2d440}, {0x13c6420, 0xc0158c2d80}, {0x0, 0x0, 0x0})
    io/io.go:411 +0x9d
io.Copy(...)
    io/io.go:388
chainguard.dev/apko/pkg/tarfs.(*memFS).WriteFile(0xc0006abf18?, {0xc0127499b0?, 0xc014ed18c0?}, {0xc007296000, 0x320, 0x321}, 0xea05ee8?)
    chainguard.dev/apko@v0.14.8/pkg/tarfs/fs.go:563 +0x186
chainguard.dev/apko/pkg/apk/apk.(*APK).InitKeyring.func1()
    chainguard.dev/apko@v0.14.8/pkg/apk/apk/implementation.go:439 +0x7f4
golang.org/x/sync/errgroup.(*Group).Go.func1()
    golang.org/x/sync@v0.7.0/errgroup/errgroup.go:78 +0x56
created by golang.org/x/sync/errgroup.(*Group).Go in goroutine 35972
    golang.org/x/sync@v0.7.0/errgroup/errgroup.go:75 +0x96

Error: The terraform-provider-apko_v0.15.12 plugin crashed!

This is always indicative of a bug within the plugin. It would be immensely
helpful if you could report the crash with the plugin's maintainers so that it
can be fixed. The output above should help diagnose the issue.
imjasonh commented 3 months ago

Here's the offending part: https://github.com/chainguard-dev/apko/blob/v0.14.8/pkg/tarfs/fs.go#L924C1-L925C1