From 87bd184a215abd91b6e8c4639576f0c8f9d9d59e Mon Sep 17 00:00:00 2001 From: Jason Harley Date: Wed, 11 Oct 2023 17:55:37 -0400 Subject: [PATCH] bugfix: ensure Summary is set on SDK v2 Diagnostics (#378) SDKv2 based resources reporting errors that weren't complete RFC7807-style errors reported something like the following: > Error: Empty Summary: This is always a bug in the provider and should be reported to the provider developers. This fixes that by always ensuring that "Summary" is set. --- honeycombio/resource_derived_column_test.go | 24 +++++++++++++++++++++ honeycombio/type_helpers.go | 4 ++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/honeycombio/resource_derived_column_test.go b/honeycombio/resource_derived_column_test.go index 92d0962b..3f9ef934 100644 --- a/honeycombio/resource_derived_column_test.go +++ b/honeycombio/resource_derived_column_test.go @@ -2,6 +2,7 @@ package honeycombio import ( "fmt" + "regexp" "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" @@ -50,6 +51,29 @@ func TestAccHoneycombioDerivedColumn_basic(t *testing.T) { }) } +func TestAccHoneycombioDerivedColumn_error(t *testing.T) { + dataset := testAccDataset() + + resource.Test(t, resource.TestCase{ + PreCheck: testAccPreCheck(t), + ProviderFactories: testAccProviderFactories, + IDRefreshName: "honeycombio_derived_column.test", + Steps: []resource.TestStep{ + { + Config: fmt.Sprintf(` +resource "honeycombio_derived_column" "invalid_column_in_expression" { + alias = "invalid_column_in_expression" + expression = "LOG10($invalid_column)" + + dataset = "%s" +} +`, dataset), + ExpectError: regexp.MustCompile(`Error: unknown column name: invalid_column`), + }, + }, + }) +} + func testAccDerivedColumnConfig(dataset, alias string) string { return fmt.Sprintf(` resource "honeycombio_derived_column" "test" { diff --git a/honeycombio/type_helpers.go b/honeycombio/type_helpers.go index 8d99b547..5f78dffe 100644 --- a/honeycombio/type_helpers.go +++ b/honeycombio/type_helpers.go @@ -464,8 +464,8 @@ func diagFromDetailedErr(err honeycombio.DetailedError) diag.Diagnostics { } else { diags = append(diags, diag.Diagnostic{ Severity: diag.Error, - Summary: err.Title, - Detail: err.Message, + Summary: err.Message, + Detail: err.Title, }) }