hashicorp/terraform · error

provider has no function named

Error message

provider has no function named %q

What it means

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.

Solutions

  1. Refresh the provider schema via GetProviderSchema before calling CallFunction
  2. Verify req.FunctionName is in the declared Functions map (encode_tfvars, decode_tfvars, encode_expr)
  3. Route the call to the provider that actually owns the function name
Defensive patterns

Strategy: validation

Validate before calling

// Before calling CallFunction, confirm the function is declared in the schema.
schema := p.GetProviderSchema()
if _, ok := schema.Functions[req.FunctionName]; !ok {
    // route to the provider that owns the function, or fail fast
}
// Known names: encode_tfvars, decode_tfvars, encode_expr

Type guard

func isBuiltinTerraformFunction(name string) bool {
    switch name {
    case "encode_tfvars", "decode_tfvars", "encode_expr":
        return true
    }
    return false
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of hashicorp/terraform@d32a084675 (2026-08-11). Data as JSON: /api/errors/49baf5af0ee52ab4. Report an issue: GitHub.

Appendix: source

Thrown at internal/builtin/providers/terraform/provider.go:260

}

// CloseEphemeralResource implements providers.Interface.
func (p *Provider) CloseEphemeralResource(req providers.CloseEphemeralResourceRequest) providers.CloseEphemeralResourceResponse {
	var resp providers.CloseEphemeralResourceResponse
	resp.Diagnostics = resp.Diagnostics.Append(fmt.Errorf("unsupported ephemeral resource type %q", req.TypeName))
	return resp
}

// CallFunction would call a function contributed by this provider, but this
// provider has no functions and so this function just panics.
func (p *Provider) CallFunction(req providers.CallFunctionRequest) providers.CallFunctionResponse {
	fn, ok := functions[req.FunctionName]
	if !ok {
		// Should not get here if the caller is behaving correctly, because
		// we don't declare any functions in our schema that we don't have
		// implementations for.
		return providers.CallFunctionResponse{
			Err: fmt.Errorf("provider has no function named %q", req.FunctionName),
		}
	}

	// NOTE: We assume that none of the arguments can be marked, because we're
	// expecting to be called from logic in Terraform Core that strips marks
	// before calling a provider-contributed function, and then reapplies them
	// afterwards.

	result, err := fn(req.Arguments)
	if err != nil {
		return providers.CallFunctionResponse{
			Err: err,
		}
	}
	return providers.CallFunctionResponse{
		Result: result,
	}
}

View on GitHub (pinned to d32a084675)