{"record":{"id":"49baf5af0ee52ab4","repo":"hashicorp/terraform","slug":"provider-has-no-function-named-q","errorCode":null,"errorMessage":"provider has no function named %q","messagePattern":"provider has no function named %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/builtin/providers/terraform/provider.go","lineNumber":260,"sourceCode":"}\n\n// CloseEphemeralResource implements providers.Interface.\nfunc (p *Provider) CloseEphemeralResource(req providers.CloseEphemeralResourceRequest) providers.CloseEphemeralResourceResponse {\n\tvar resp providers.CloseEphemeralResourceResponse\n\tresp.Diagnostics = resp.Diagnostics.Append(fmt.Errorf(\"unsupported ephemeral resource type %q\", req.TypeName))\n\treturn resp\n}\n\n// CallFunction would call a function contributed by this provider, but this\n// provider has no functions and so this function just panics.\nfunc (p *Provider) CallFunction(req providers.CallFunctionRequest) providers.CallFunctionResponse {\n\tfn, ok := functions[req.FunctionName]\n\tif !ok {\n\t\t// Should not get here if the caller is behaving correctly, because\n\t\t// we don't declare any functions in our schema that we don't have\n\t\t// implementations for.\n\t\treturn providers.CallFunctionResponse{\n\t\t\tErr: fmt.Errorf(\"provider has no function named %q\", req.FunctionName),\n\t\t}\n\t}\n\n\t// NOTE: We assume that none of the arguments can be marked, because we're\n\t// expecting to be called from logic in Terraform Core that strips marks\n\t// before calling a provider-contributed function, and then reapplies them\n\t// afterwards.\n\n\tresult, err := fn(req.Arguments)\n\tif err != nil {\n\t\treturn providers.CallFunctionResponse{\n\t\t\tErr: err,\n\t\t}\n\t}\n\treturn providers.CallFunctionResponse{\n\t\tResult: result,\n\t}\n}","sourceCodeStart":242,"sourceCodeEnd":278,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/builtin/providers/terraform/provider.go#L242-L278","documentation":"Returned by `CallFunction` (provider.go:260) when the requested `FunctionName` is not a key in the `functions` map (`encode_tfvars`, `decode_tfvars`, `encode_expr`). The code comment notes this 'should not get here' if the caller respects the schema, because `GetProviderSchema().Functions` advertises exactly those three names.","triggerScenarios":"An HCL expression `provider::terraform::<unknown>()`, or a Go caller of `providers.Interface.CallFunction` passing a `FunctionName` not in the three known functions.","commonSituations":"Typo in a function name; an experimental runtime dispatching functions without consulting `GetProviderSchema().Functions`; a version skew where a caller expects a function added in a newer Terraform than the provider build.","solutions":["Use only `encode_tfvars`, `decode_tfvars`, or `encode_expr` with the built-in terraform provider.","Introspect `GetProviderSchema().Functions` and only dispatch names present in that map.","Upgrade or downgrade the caller/provider together so the expected function is advertised in the schema."],"exampleFix":"// before\nprovider::terraform::encode_tfvar(local.obj)\n\n// after\nprovider::terraform::encode_tfvars(local.obj)","handlingStrategy":"validation","validationCode":"schema := provider.GetProviderSchema()\ndecl, ok := schema.Functions[req.FunctionName]\nif !ok {\n    return fmt.Errorf(\"function %q not advertised by terraform provider\", req.FunctionName)\n}\n_ = decl","typeGuard":"func providerSupportsFunction(schema providers.GetProviderSchemaResponse, name string) bool {\n    _, ok := schema.Functions[name]\n    return ok\n}","tryCatchPattern":null,"preventionTips":["Introspect GetProviderSchema().Functions before dispatching CallFunction.","Pin caller and provider versions together to avoid advertising/calling skew.","Spell function names exactly: encode_tfvars, decode_tfvars, encode_expr."],"tags":["terraform","builtin-provider","function","dispatch","defensive","provider-interface"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}