Skip to content

Commit

Permalink
fix panic on http response with no status code
Browse files Browse the repository at this point in the history
  • Loading branch information
smithclay committed May 17, 2022
1 parent c9c36e2 commit df6dec1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lightstep/resource_metric_dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package lightstep
import (
"context"
"fmt"
"github.com/lightstep/terraform-provider-lightstep/client"
"net/http"
"strings"

"github.com/lightstep/terraform-provider-lightstep/client"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
Expand Down Expand Up @@ -122,7 +123,7 @@ func resourceMetricDashboardRead(ctx context.Context, d *schema.ResourceData, m
dashboard, err := c.GetMetricDashboard(ctx, d.Get("project_name").(string), d.Id())
if err != nil {
apiErr := err.(client.APIResponseCarrier)
if apiErr.GetHTTPResponse().StatusCode == http.StatusNotFound {
if apiErr.GetHTTPResponse() != nil && apiErr.GetHTTPResponse().StatusCode == http.StatusNotFound {
d.SetId("")
return diags
}
Expand Down

0 comments on commit df6dec1

Please sign in to comment.