{"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":"exception","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/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/builtin/providers/terraform/provider.go#L242-L278","documentation":"CallFunction looks up req.FunctionName in the functions map, which contains only encode_tfvars, decode_tfvars, and encode_expr. An unknown name means Core asked for a function the provider never declared in its schema — an invariant violation on the caller side.","triggerScenarios":"A providers.CallFunctionRequest whose FunctionName is not one of encode_tfvars/decode_tfvars/encode_expr; a stale schema cache advertising a function the provider no longer (or never did) implement.","commonSituations":"Version skew between Core's cached schema and the built-in provider binary; a Core bug dispatching a function belonging to a different provider to the built-in terraform address; a renamed/removed function after upgrade.","solutions":["Refresh the provider schema via GetProviderSchema before calling CallFunction","Verify req.FunctionName is in the declared Functions map (encode_tfvars, decode_tfvars, encode_expr)","Route the call to the provider that actually owns the function name"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Before calling CallFunction, confirm the function is declared in the schema.\nschema := p.GetProviderSchema()\nif _, ok := schema.Functions[req.FunctionName]; !ok {\n    // route to the provider that owns the function, or fail fast\n}\n// Known names: encode_tfvars, decode_tfvars, encode_expr","typeGuard":"func isBuiltinTerraformFunction(name string) bool {\n    switch name {\n    case \"encode_tfvars\", \"decode_tfvars\", \"encode_expr\":\n        return true\n    }\n    return false\n}","tryCatchPattern":null,"preventionTips":["Refresh GetProviderSchema after upgrades so Core's function map matches the provider","Validate req.FunctionName against the declared Functions map before dispatch","Route function calls to the provider address that owns each function"],"tags":["terraform","go","provider","functions","invariant"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}