diff --git a/internal/decoder/validations/unreferenced_origin.go b/internal/decoder/validations/unreferenced_origin.go index ad5f550d0..aa19bfdf7 100644 --- a/internal/decoder/validations/unreferenced_origin.go +++ b/internal/decoder/validations/unreferenced_origin.go @@ -27,6 +27,13 @@ func UnreferencedOrigins(ctx context.Context, pathCtx *decoder.PathContext) lang continue } + _, ok = origin.(reference.LocalOrigin) + if !ok { + // we avoid reporting on origins outside of the current module + // for now, to reduce complexity and reduce performance impact + continue + } + // we only initially validate variables // resources and data sources can have unknown schema // and will be researched at a later point diff --git a/internal/decoder/validations/unreferenced_origin_test.go b/internal/decoder/validations/unreferenced_origin_test.go index f36b6122d..2f0457a9c 100644 --- a/internal/decoder/validations/unreferenced_origin_test.go +++ b/internal/decoder/validations/unreferenced_origin_test.go @@ -50,6 +50,28 @@ func TestUnreferencedOrigins(t *testing.T) { }, }, }, + { + name: "unsupported path origins (module input)", + origins: reference.Origins{ + reference.PathOrigin{ + Range: hcl.Range{ + Filename: "test.tf", + Start: hcl.Pos{}, + End: hcl.Pos{}, + }, + TargetAddr: lang.Address{ + lang.RootStep{Name: "var"}, + lang.AttrStep{Name: "foo"}, + }, + TargetPath: lang.Path{ + Path: "./submodule", + LanguageID: "terraform", + }, + Constraints: reference.OriginConstraints{}, + }, + }, + want: lang.DiagnosticsMap{}, + }, { name: "many undeclared variables", origins: reference.Origins{