Open iliazlobin opened 3 years ago
When using the log collection feature with option blocks of different types it panics.
In an empty directory, create a file echo.variant that resembles an example with the following content:
echo.variant
option "bool-opt" { default = false description = "" type = bool } option "string-opt" { default = "default-value" description = "" type = string } job "echo" { parameter "message" { type = string } exec { command = "echo" args = ["text=${param.message}"] } } job "echotest" { step "first-step" { run "echo" { message = "{\"a\":\"b\"}" } } log { collect { condition = event.type == "run" && can(event.run.job == "echo") format = "run=${jsonencode(event.run)}" } file = "${context.sourcedir}/log.txt" } }
Run echotest job and receive an error:
echotest
panic: inconsistent map element types (cty.String then cty.Bool) goroutine 15 [running]: github.com/zclconf/go-cty/cty.MapVal(0xc000724e18, 0xc000724e18, 0xc0009c33a9, 0x7, 0xc000724f70) /home/runner/go/pkg/mod/github.com/zclconf/go-cty@v1.6.2-0.20201013200640-e5225636c8c2/cty/value_init.go:207 +0x4b8 github.com/mumoshu/variant2/pkg/app.goToCty(0x23bcb20, 0xc00070dad0, 0x14, 0x0, 0x0, 0x0, 0x2795d3d, 0x0) /home/runner/work/variant2/variant2/pkg/app/go_to_cty.go:28 +0x6fb github.com/mumoshu/variant2/pkg/app.(*RunEvent).toCty(0xc0007018c0, 0xc000725310, 0x27673f9, 0x4, 0xc0007253e8) /home/runner/work/variant2/variant2/pkg/app/log.go:54 +0x31a github.com/mumoshu/variant2/pkg/app.Event.toCty(0x27665c2, 0x3, 0xc00a0128303818ac, 0x1978119, 0x3e73ac0, 0xc0007018c0, 0x0, 0xc000113608, 0x8, 0xc0001135c8, ...) /home/runner/work/variant2/variant2/pkg/app/log.go:38 +0x393 github.com/mumoshu/variant2/pkg/app.(*App).newLogCollector.func1(0x27665c2, 0x3, 0xc00a0128303818ac, 0x1978119, 0x3e73ac0, 0xc0007018c0, 0x0, 0xc0007043f8, 0xc00070d8f0, 0xc000704438, ...) /home/runner/work/variant2/variant2/pkg/app/app_log.go:18 +0x1e5 github.com/mumoshu/variant2/pkg/app.(*LogCollector).Collect(0xc00071dd00, 0x27665c2, 0x3, 0xc00a0128303818ac, 0x1978119, 0x3e73ac0, 0xc0007018c0, 0x0, 0xc0001139a0, 0x40da30, ...) /home/runner/work/variant2/variant2/pkg/app/log.go:197 +0x65 github.com/mumoshu/variant2/pkg/app.(*EventLogger).append(0xc000421f00, 0x27665c2, 0x3, 0xc00a0128303818ac, 0x1978119, 0x3e73ac0, 0xc0007018c0, 0x0, 0x0, 0x0) /home/runner/work/variant2/variant2/pkg/app/log.go:132 +0x1ee github.com/mumoshu/variant2/pkg/app.(*EventLogger).LogRun(0xc000421f00, 0xc0009c3388, 0x4, 0xc00070dad0, 0xc00070da70, 0xc00070dad0) /home/runner/work/variant2/variant2/pkg/app/log.go:110 +0x105 github.com/mumoshu/variant2/pkg/app.(*App).run(0xc000421c80, 0xc000701780, 0xc000421f00, 0xc0009c3388, 0x4, 0xc00070dad0, 0x1, 0x0, 0x0, 0x0) /home/runner/work/variant2/variant2/pkg/app/app.go:68 +0x35c github.com/mumoshu/variant2/pkg/app.(*App).dispatchRunJob(0xc000421c80, 0xc000421f00, 0xc000701780, 0xc00070d990, 0x0, 0x1, 0x0, 0x0, 0x0) /home/runner/work/variant2/variant2/pkg/app/app.go:874 +0xc8 github.com/mumoshu/variant2/pkg/app.(*App).runJobAndUpdateContext(0xc000421c80, 0xc000421f00, 0xc000701780, 0xc00070d990, 0x0, 0x2d640a0, 0xc000844808, 0x406101, 0x0, 0x0, ...) /home/runner/work/variant2/variant2/pkg/app/app.go:961 +0xaa github.com/mumoshu/variant2/pkg/app.(*App).execJobSteps.func1(0x0, 0x0, 0x0) /home/runner/work/variant2/variant2/pkg/app/app.go:1015 +0xa8 github.com/mumoshu/variant2/pkg/app.(*App).execJobSteps.func4() /home/runner/work/variant2/variant2/pkg/app/app.go:1110 +0xd0 github.com/mumoshu/variant2/pkg/app.(*App).execJobSteps.func3(0xc000114a80) /home/runner/work/variant2/variant2/pkg/app/app.go:1083 +0x3b created by github.com/mumoshu/variant2/pkg/app.(*App).execJobSteps /home/runner/work/variant2/variant2/pkg/app/app.go:1081 +0xc5b
Problem statement
When using the log collection feature with option blocks of different types it panics.
Steps to reproduce
In an empty directory, create a file
echo.variant
that resembles an example with the following content:Run
echotest
job and receive an error: