Skip to content

Commit

Permalink
bugfix: ensure Summary is set on SDK v2 Diagnostics (#378)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jharley authored Oct 11, 2023
1 parent 1369e90 commit 87bd184
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
24 changes: 24 additions & 0 deletions honeycombio/resource_derived_column_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package honeycombio

import (
"fmt"
"regexp"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
Expand Down Expand Up @@ -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" {
Expand Down
4 changes: 2 additions & 2 deletions honeycombio/type_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
}

Expand Down

0 comments on commit 87bd184

Please sign in to comment.