Skip to content

Commit b0e7f3a

Browse files
improve wording and subject of error message
1 parent 6b03875 commit b0e7f3a

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

internal/terraform/context_plan_actions_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4088,8 +4088,9 @@ resource "test_object" "a" {
40884088
if !diags.HasErrors() {
40894089
t.Fatal("expected errors, got success!")
40904090
}
4091-
if diags.Err().Error() != "Configuration for triggered action does not exist: The configuration for the given action action.test_action.hello does not exist. All triggered actions must have an associated configuration." {
4092-
t.Fatal("wrong error!")
4091+
expectedErr := "action_trigger actions references non-existent action: The lifecycle action_trigger actions list contains a reference to the action \"action.test_action.hello\" that does not exist in the configuration of this module. This can likely be a typo."
4092+
if diags.Err().Error() != expectedErr {
4093+
t.Fatalf("wrong error!, got %q, expected %q", diags.Err().Error(), expectedErr)
40934094
}
40944095
}
40954096

internal/terraform/transform_config.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ func (t *ConfigTransformer) transformSingle(g *Graph, config *configs.Config) er
164164
// Verify that any actions referenced in the resource's ActionTriggers exist in this module
165165
var diags tfdiags.Diagnostics
166166
if r.Managed != nil && r.Managed.ActionTriggers != nil {
167-
for i, at := range r.Managed.ActionTriggers {
167+
for _, at := range r.Managed.ActionTriggers {
168168
for _, action := range at.Actions {
169169

170170
refs, parseRefDiags := langrefs.ReferencesInExpr(addrs.ParseRef, action.Expr)
@@ -192,9 +192,10 @@ func (t *ConfigTransformer) transformSingle(g *Graph, config *configs.Config) er
192192
if !ok {
193193
diags = diags.Append(&hcl.Diagnostic{
194194
Severity: hcl.DiagError,
195-
Summary: "Configuration for triggered action does not exist",
196-
Detail: fmt.Sprintf("The configuration for the given action %s does not exist. All triggered actions must have an associated configuration.", configAction.String()),
197-
Subject: &r.Managed.ActionTriggers[i].DeclRange,
195+
Summary: "action_trigger actions references non-existent action",
196+
Detail: fmt.Sprintf("The lifecycle action_trigger actions list contains a reference to the action %q that does not exist in the configuration of this module. This can likely be a typo.", configAction.String()),
197+
Subject: action.Expr.Range().Ptr(),
198+
Context: r.DeclRange.Ptr(),
198199
})
199200
}
200201
}

0 commit comments

Comments
 (0)