From 2b2a697c908fc4c3468650b47925b619502fbc47 Mon Sep 17 00:00:00 2001 From: Christian Mesh Date: Wed, 27 May 2026 15:59:06 -0400 Subject: [PATCH] Handle provider resource not found in compile_resource.go Signed-off-by: Christian Mesh --- .../eval/internal/tofu2024/compile_resources.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/internal/lang/eval/internal/tofu2024/compile_resources.go b/internal/lang/eval/internal/tofu2024/compile_resources.go index 571dd6f85f..d852021765 100644 --- a/internal/lang/eval/internal/tofu2024/compile_resources.go +++ b/internal/lang/eval/internal/tofu2024/compile_resources.go @@ -7,7 +7,9 @@ package tofu2024 import ( "context" + "fmt" + "github.com/hashicorp/hcl/v2" "github.com/zclconf/go-cty/cty" "github.com/opentofu/opentofu/internal/addrs" @@ -65,7 +67,16 @@ func compileModuleInstanceResource( resourceAddr.Type, ) if diags.HasErrors() { - configEvalable = exprs.ForcedErrorEvalable(diags, tfdiags.SourceRangeFromHCL(config.DeclRange)) + configEvalable = exprs.ForcedErrorEvalable(diags, tfdiags.SourceRangeFromHCL(config.TypeRange)) + } else if resourceTypeSchema == nil { + suggestion := "TODO suggestion" //TODO NodeValidatableResource.noResourceSchemaSuggestion + diags = diags.Append(&hcl.Diagnostic{ + Severity: hcl.DiagError, + Summary: "Invalid resource type", + Detail: fmt.Sprintf("The provider %s does not support resource type %q.%s", config.Provider.ForDisplay(), resourceAddr.Type, suggestion), + Subject: config.TypeRange.Ptr(), + }) + configEvalable = exprs.ForcedErrorEvalable(diags, tfdiags.SourceRangeFromHCL(config.TypeRange)) } else { spec := resourceTypeSchema.Block.DecoderSpec() configEvalable = exprs.EvalableHCLBodyWithDynamicBlocks(config.Config, spec)