Skip to content

Commit

Permalink
tfsdk: Update attribute Required/Optional/Computed diagnostic handlin…
Browse files Browse the repository at this point in the history
…g after rebase
  • Loading branch information
bflad committed Sep 1, 2021
1 parent 0e1a0c0 commit 9517ae4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
11 changes: 5 additions & 6 deletions tfsdk/attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,12 +247,11 @@ func (a Attribute) validate(ctx context.Context, req ValidateAttributeRequest, r
}

if !a.Required && !a.Optional && !a.Computed {
resp.Diagnostics = append(resp.Diagnostics, &tfprotov6.Diagnostic{
Severity: tfprotov6.DiagnosticSeverityError,
Summary: "Invalid Attribute Definition",
Detail: "Attribute missing Required, Optional, or Computed definition. This is always a problem with the provider and should be reported to the provider developer.",
Attribute: req.AttributePath,
})
resp.Diagnostics.AddAttributeError(
req.AttributePath,
"Invalid Attribute Definition",
"Attribute missing Required, Optional, or Computed definition. This is always a problem with the provider and should be reported to the provider developer.",
)

return
}
Expand Down
13 changes: 6 additions & 7 deletions tfsdk/attribute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -777,13 +777,12 @@ func TestAttributeValidate(t *testing.T) {
},
},
resp: ValidateAttributeResponse{
Diagnostics: []*tfprotov6.Diagnostic{
{
Severity: tfprotov6.DiagnosticSeverityError,
Summary: "Invalid Attribute Definition",
Detail: "Attribute missing Required, Optional, or Computed definition. This is always a problem with the provider and should be reported to the provider developer.",
Attribute: tftypes.NewAttributePath().WithAttributeName("test"),
},
Diagnostics: diag.Diagnostics{
diag.NewAttributeErrorDiagnostic(
tftypes.NewAttributePath().WithAttributeName("test"),
"Invalid Attribute Definition",
"Attribute missing Required, Optional, or Computed definition. This is always a problem with the provider and should be reported to the provider developer.",
),
},
},
},
Expand Down

0 comments on commit 9517ae4

Please sign in to comment.