Commit a282ce6
authored
feat: Better error when panic happens in
#### Summary
We have a test in our ClickHouse destination that is flaky https://github.com/cloudquery/cloudquery/actions/runs/15976814323/job/45061355720#step:9:16
```
FAIL: TestPlugin/TestInsert/All (2.80s)
panic: json: error calling MarshalJSON for type *array.Struct: json: error calling MarshalJSON for type json.RawMessage: unexpected character '' [recovered]
panic: json: error calling MarshalJSON for type *array.Struct: json: error calling MarshalJSON for type json.RawMessage: unexpected character ''
goroutine 74 [running]:
testing.tRunner.func1.2({0x10f42e0, 0xc00104ccf0})
/opt/hostedtoolcache/go/1.24.3/x64/src/testing/testing.go:1734 +0x3eb
testing.tRunner.func1()
/opt/hostedtoolcache/go/1.24.3/x64/src/testing/testing.go:1737 +0x696
panic({0x10f42e0?, 0xc00104ccf0?})
/opt/hostedtoolcache/go/1.24.3/x64/src/runtime/panic.go:792 +0x132
github.com/apache/arrow-go/v18/arrow/array.(*List).GetOneForMarshal(0xc00140be00, 0x0)
/home/runner/go/pkg/mod/github.com/apache/arrow-go/v18@v18.3.1/arrow/array/list.go:110 +0x33b
github.com/apache/arrow-go/v18/arrow/array.(*Struct).GetOneForMarshal(0xc000737b00, 0x0)
/home/runner/go/pkg/mod/github.com/apache/arrow-go/v18@v18.3.1/arrow/array/struct.go:212 +0x2d6
github.com/apache/arrow-go/v18/arrow/array.(*Struct).MarshalJSON(0xc000737b00)
/home/runner/go/pkg/mod/github.com/apache/arrow-go/v18@v18.3.1/arrow/array/struct.go:226 +0x189
github.com/goccy/go-json/internal/encoder.AppendMarshalJSON(0xc000179110, 0xc0009b9860, {0xc000ffdc00, 0x0, 0x400}, {0x119ea80, 0xc000737b00})
/home/runner/go/pkg/mod/github.com/goccy/go-json@v0.10.5/internal/encoder/encoder.go:435 +0x472
github.com/goccy/go-json/internal/encoder/vm.appendMarshalJSON(0xc000179110, 0xc0009b9860, {0xc000ffdc00, 0x0, 0x400}, {0x119ea80, 0xc000737b00})
/home/runner/go/pkg/mod/github.com/goccy/go-json@v0.10.5/internal/encoder/vm/util.go:152 +0x85
github.com/goccy/go-json/internal/encoder/vm.Run(0xc000179110, {0xc000ffdc00, 0x0, 0x400}, 0xc000df6cb0)
/home/runner/go/pkg/mod/github.com/goccy/go-json@v0.10.5/internal/encoder/vm/vm.go:271 +0x63c5
github.com/goccy/go-json.encodeRunCode(0xc000179110, {0xc000ffdc00, 0x0, 0x400}, 0xc000df6cb0)
/home/runner/go/pkg/mod/github.com/goccy/go-json@v0.10.5/encode.go:310 +0x235
github.com/goccy/go-json.encode(0xc000179110, {0x119ea80, 0xc000737b00})
/home/runner/go/pkg/mod/github.com/goccy/go-json@v0.10.5/encode.go:235 +0x47d
github.com/goccy/go-json.marshal({0x119ea80, 0xc000737b00}, {0x0, 0x0, 0x3?})
/home/runner/go/pkg/mod/github.com/goccy/go-json@v0.10.5/encode.go:150 +0x16a
github.com/goccy/go-json.MarshalWithOption(...)
/home/runner/go/pkg/mod/github.com/goccy/go-json@v0.10.5/json.go:185
github.com/goccy/go-json.Marshal({0x119ea80, 0xc000737b00})
/home/runner/go/pkg/mod/github.com/goccy/go-json@v0.10.5/json.go:170 +0x3b
github.com/apache/arrow-go/v18/internal/json.Marshal(...)
/home/runner/go/pkg/mod/github.com/apache/arrow-go/v18@v18.3.1/internal/json/json.go:38
github.com/apache/arrow-go/v18/arrow/array.(*List).GetOneForMarshal(0xc00140b2c0, 0x0)
/home/runner/go/pkg/mod/github.com/apache/arrow-go/v18@v18.3.1/arrow/array/list.go:108 +0x26c
github.com/apache/arrow-go/v18/arrow/array.(*List).MarshalJSON(0xc00140b2c0)
/home/runner/go/pkg/mod/github.com/apache/arrow-go/v18@v18.3.1/arrow/array/list.go:124 +0x189
github.com/apache/arrow-go/v18/arrow/array.stringAt({0x140ee40, 0xc00104d830}, 0x2)
/home/runner/go/pkg/mod/github.com/apache/arrow-go/v18@v18.3.1/arrow/array/diff.go:110 +0xbdb
github.com/apache/arrow-go/v18/arrow/array.Edits.UnifiedDiff({0xc000516000, 0x5, 0x140ee40?}, {0x140ee40, 0xc00104d830}, {0x140ee40, 0xc00104d800})
/home/runner/go/pkg/mod/github.com/apache/arrow-go/v18@v18.3.1/arrow/array/diff.go:72 +0x558
github.com/cloudquery/plugin-sdk/v4/plugin.TableDiff({0x1409f58, 0xc000298000}, {0x1409f58, 0xc000298030})
/home/runner/go/pkg/mod/github.com/cloudquery/plugin-sdk/v4@v4.84.2/plugin/diff.go:42 +0x5da
```
It's hard to debug the test since:
1. It's flaky
2. We don't have enough information when it fails
This PR tries to error out with a bit more information on the data that was used while triggering the panic
---UnifiedDiff (#2217)1 parent c1375bb commit a282ce6
1 file changed
+20
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
16 | 35 | | |
17 | 36 | | |
18 | 37 | | |
| |||
39 | 58 | | |
40 | 59 | | |
41 | 60 | | |
42 | | - | |
| 61 | + | |
43 | 62 | | |
44 | 63 | | |
45 | 64 | | |
| |||
0 commit comments