steampipe-plugin-sdk icon indicating copy to clipboard operation
steampipe-plugin-sdk copied to clipboard

TIMESTAMP column conversion fails with error when the passed in value is nil (it should set column to null)

Open e-gineer opened this issue 3 years ago • 0 comments

When the SDK attempts to convert a timestamp, it fails if the passed value is nil with the error:

Error: failed to populate column 'published_at': rpc error: code = Internal desc = transform convertTimestamp failed with panic runtime error: invalid memory address or nil pointer dereference

I'm seeing this from the automatic TIMESTAMP column converter.

This issue comes from the github_release table when the release has never been published (and thus has no timestamp). I believe the correct value would be null for the column.

Here is the column definition: https://github.com/turbot/steampipe-plugin-github/blob/main/github/table_github_release.go#L45

And here is an updated version of the timestamp conversion transformer I'm using:

func convertTimestamp(ctx context.Context, input *transform.TransformData) (interface{}, error) {
  switch t := input.Value.(type) {
  case *github.Timestamp:
    return t.Format(time.RFC3339), nil 
  default:
    return nil, nil 
  }
}

e-gineer avatar Aug 17 '21 19:08 e-gineer