Skip to content

Commit

Permalink
fix panic when import id is empty string
Browse files Browse the repository at this point in the history
We can only detect this during evaluation since the import id
is an hcl expression.

Fixes #33505
  • Loading branch information
DanielMSchmidt committed Feb 6, 2024
1 parent 64cd0da commit e0cb633
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions internal/terraform/eval_import.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,15 @@ func evaluateImportIdExpression(expr hcl.Expression, ctx EvalContext, keyData in
})
}

if importId == "" {
return "", diags.Append(&hcl.Diagnostic{
Severity: hcl.DiagError,
Summary: "Invalid import id argument",
Detail: fmt.Sprintf("The import ID value is \"\", please provide a valid value."),

Check failure on line 79 in internal/terraform/eval_import.go

View workflow job for this annotation

GitHub Actions / Code Consistency Checks

unnecessary use of fmt.Sprintf (S1039)
Subject: expr.Range().Ptr(),
})
}

return importId, diags
}

Expand Down

0 comments on commit e0cb633

Please sign in to comment.