From 336145c384a274249eb18cc62a88db15d0784c69 Mon Sep 17 00:00:00 2001 From: James Bardin Date: Thu, 15 Feb 2024 11:53:09 -0500 Subject: [PATCH] update diagnostic message --- internal/lang/eval.go | 2 +- internal/terraform/context_functions_test.go | 2 +- internal/terraform/context_validate_test.go | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/lang/eval.go b/internal/lang/eval.go index 954715fb09..8397ebd66e 100644 --- a/internal/lang/eval.go +++ b/internal/lang/eval.go @@ -571,7 +571,7 @@ func checkForUnknownFunctionDiags(diags hcl.Diagnostics) hcl.Diagnostics { // no other functions exist for this provider, so hint that the user may // need to include it in the configuration. - d.Detail = fmt.Sprintf(`There is no function named "%s%s". The provider %q may need to be added to the required_providers block within the module configuration.`, namespace, name, namespaceParts[1]) + d.Detail = fmt.Sprintf(`There is no function named "%s%s". Ensure that provider name %q is declared in this module's required_providers block, and that this provider offers a function named %q.`, namespace, name, namespaceParts[1], name) } return diags diff --git a/internal/terraform/context_functions_test.go b/internal/terraform/context_functions_test.go index 4e90769ab2..a2b71d298d 100644 --- a/internal/terraform/context_functions_test.go +++ b/internal/terraform/context_functions_test.go @@ -256,7 +256,7 @@ func TestContext2Validate_providerFunctionDiagnostics(t *testing.T) { output "first" { value = provider::test::echo("input") }`}), - `The provider "test" may need to be added to the required_providers block within the module configuration.`, + `Ensure that provider name "test" is declared in this module's required_providers block, and that this provider offers a function named "echo"`, }, { "invalid namespace", diff --git a/internal/terraform/context_validate_test.go b/internal/terraform/context_validate_test.go index 6c8712815f..561eb58725 100644 --- a/internal/terraform/context_validate_test.go +++ b/internal/terraform/context_validate_test.go @@ -2631,7 +2631,7 @@ output "result" { if !diags.HasErrors() { t.Fatal("unexpected success") } - if got, want := diags.Err().Error(), "Call to unknown function: There is no function named \"cout_e\" in namespace provider::test::."; !strings.Contains(got, want) { + if got, want := diags.Err().Error(), `Unknown provider function: The function "cout_e" is not available from the provider "test"`; !strings.Contains(got, want) { t.Errorf("wrong error message\nwant substring: %s\ngot: %s", want, got) } @@ -2666,7 +2666,7 @@ output "result" { if !diags.HasErrors() { t.Fatal("unexpected success") } - if got, want := diags.Err().Error(), "Call to unknown function: There are no functions in namespace \"provider::toast::\"."; !strings.Contains(got, want) { + if got, want := diags.Err().Error(), `Unknown provider function: There is no function named "provider::toast::count_e`; !strings.Contains(got, want) { t.Errorf("wrong error message\nwant substring: %s\ngot: %s", want, got) } }) @@ -2870,7 +2870,7 @@ output "result" { } // Module author must declare a provider requirement in order to // import a provider's functions. - if got, want := diags.Err().Error(), "Call to unknown function: There are no functions in namespace \"provider::test::\"."; !strings.Contains(got, want) { + if got, want := diags.Err().Error(), `Unknown provider function: There is no function named "provider::test::count_e"`; !strings.Contains(got, want) { t.Errorf("wrong error message\nwant substring: %s\ngot: %s", want, got) } })