Skip to content

Commit 83813de

Browse files
authored
fix: Don't panic on empty-string for timestamp (#489)
#### Summary Fixes this panic: ``` 12:22PM ERR column resolver finished with panic error={} client=pagerduty column=created_at duration=0.138344 module=pagerduty-src stack="failed to set column created_at: cannot parse as Timestamptz\ngoroutine 402 [running]:\nruntime/debug.Stack()\n\t/usr/local/Cellar/go/1.19.1/libexec/src/runtime/debug/stack.go:24 +0x65\ngithub.com/cloudquery/plugin-sdk/plugins.(*SourcePlugin).resolveColumn.func1()\n\t/Users/shimonp/projects/plugin-sdk-shimonp21/plugins/source_scheduler_dfs.go:226 +0x86\npanic({0x163c740, 0xc00049a860})\n\t/usr/local/Cellar/go/1.19.1/libexec/src/runtime/panic.go:884 +0x212\ngithub.com/cloudquery/plugin-sdk/schema.(*Resource).Set(0xc0005e8740?, {0x16f71e7, 0xa}, {0x15fb260?, 0xc0000e6158?})\n\t/Users/shimonp/projects/plugin-sdk-shimonp21/schema/resource.go:74 +0x155\ngithub.com/cloudquery/plugin-sdk/schema.PathResolver.func1({0x18?, 0x1676020?}, {0xc0000be001?, 0xc0003a1a58?}, 0xc0005e8740, {{0x16f71e7, 0xa}, 0x9, {0x0, 0x0}, ...})\n\t/Users/shimonp/projects/plugin-sdk-shimonp21/schema/resolvers.go:17 +0x73\ngithub.com/cloudquery/plugin-sdk/plugins.(*SourcePlugin).resolveColumn(0xc000294000, {0x17f5398, 0xc000516e40}, {{0x17f3878, 0xc00026a470}, 0x1, {0x0, 0x0}, {0xc000418a00, 0x5a, ...}, ...}, ...)\n\t/Users/shimonp/projects/plugin-sdk-shimonp21/plugins/source_scheduler_dfs.go:233 +0x1cd\ngithub.com/cloudquery/plugin-sdk/plugins.(*SourcePlugin).resolveResource(0xc000294000, {0x17f53d0?, 0xc000319b60?}, 0xc0001f8f80, {0x17ef700, 0xc00034a7e0}, 0x14?, {0x16c49c0, 0xc0000e6100})\n\t/Users/shimonp/projects/plugin-sdk-shimonp21/plugins/source_scheduler_dfs.go:209 +0x805\ngithub.com/cloudquery/plugin-sdk/plugins.(*SourcePlugin).resolveResourcesDfs.func1.1()\n\t/Users/shimonp/projects/plugin-sdk-shimonp21/plugins/source_scheduler_dfs.go:148 +0x105\ncreated by github.com/cloudquery/plugin-sdk/plugins.(*SourcePlugin).resolveResourcesDfs.func1\n\t/Users/shimonp/projects/plugin-sdk-shimonp21/plugins/source_scheduler_dfs.go:144 +0xf6\n" table=pagerduty_user_notification_rules ```
1 parent cb5f6bb commit 83813de

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

schema/timestamptz.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ func (dst Timestamptz) Get() interface{} {
123123
}
124124

125125
func (dst *Timestamptz) DecodeText(src []byte) error {
126-
if src == nil {
126+
if len(src) == 0 {
127127
*dst = Timestamptz{Status: Null}
128128
return nil
129129
}

schema/timestamptz_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,15 @@ func TestTimestamptzSet(t *testing.T) {
3232
{source: "2150-10-15 07:25:09.75007611 +0000 UTC", result: Timestamptz{Time: time.Date(2150, 10, 15, 7, 25, 9, 750076110, time.UTC), Status: Present}},
3333
{source: timeInstance.String(), result: Timestamptz{Time: time.Date(2105, 7, 23, 22, 23, 37, 750076110, time.UTC), Status: Present}},
3434
{source: Timestamp{timeInstance}, result: Timestamptz{Time: time.Date(2105, 7, 23, 22, 23, 37, 750076110, time.UTC), Status: Present}},
35+
{source: "", result: Timestamptz{Status: Null}},
3536
}
3637

3738
for i, tt := range successfulTests {
3839
var r Timestamptz
3940
err := r.Set(tt.source)
4041
if err != nil {
4142
t.Errorf("%d: %v", i, err)
43+
continue
4244
}
4345

4446
if !r.Equal(&tt.result) {

0 commit comments

Comments
 (0)