chainloop
chainloop copied to clipboard
Panic when adding an empty material
Given this material example1.json:
[]
We get a panic when adding it to an attestation:
> cl att add --value example1.json
WRN API contacted in insecure mode
panic: interface conversion: interface {} is []interface {}, not map[string]interface {}
goroutine 1 [running]:
github.com/chainloop-dev/chainloop/pkg/attestation/crafter/materials.(*CSAFCrafter).Craft(0x14000a4f260, {0x103723a68, 0x10512f580}, {0x16f6cf60a, 0xa})
/home/runner/work/chainloop/chainloop/pkg/attestation/crafter/materials/csaf.go:105 +0x464
github.com/chainloop-dev/chainloop/pkg/attestation/crafter/materials.Craft({0x103723a68, 0x10512f580}, 0x1400100e000, {0x16f6cf60a, 0xa}, 0x14000663740, {0x1036f8fe0, 0x10512fb40}, 0x1400108e108)
/home/runner/work/chainloop/chainloop/pkg/attestation/crafter/materials/materials.go:196 +0x3c4
github.com/chainloop-dev/chainloop/pkg/attestation/crafter.(*Crafter).addMaterial(0x140011872d0, {0x103723a68, 0x10512f580}, 0x1400100e000, {0x0, 0x0}, {0x16f6cf60a, 0xa}, 0x14000000008?, 0x140009345d0)
/home/runner/work/chainloop/chainloop/pkg/attestation/crafter/crafter.go:515 +0x80
...
Also, when adding a completely empty material example2.json:
We get a control plane error:
cl att add --value example2.json
WRN API contacted in insecure mode
INF uploading empty.json - sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
ERR adding material: crafting material: upload and craft error: uploading material: rpc error: code = Internal desc = server error
We can see this in the CAS logs:
cas-1 | {"level":"error","ts":1726654271.1677432,"component":"service","msg":"crafting image: content is empty","stacktrace":"github.com/go-kratos/kratos/contrib/log/zap/v2.(*Logger).Log\n\t/home/runner/go/pkg/mod/github.com/go-kratos/kratos/contrib/log/zap/[email protected]/zap.go:41\ngithub.com/go-kratos/kratos/v2/log.(*logger).Log\n\t/home/runner/go/pkg/mod/github.com/go-kratos/kratos/[email protected]/log/log.go:30\ngithub.com/go-kratos/kratos/v2/log.(*Helper).Error\n\t/home/runner/go/pkg/mod/github.com/go-kratos/kratos/[email protected]/log/helper.go:121\ngithub.com
...