{"record":{"id":"6585bbcc01f67561","repo":"hashicorp/terraform","slug":"protoresp-error-text","errorCode":null,"errorMessage":"${protoResp.Error.Text}","messagePattern":"\\$\\{protoResp\\.Error\\.Text\\}","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/plugin/grpc_provider.go","lineNumber":1296,"sourceCode":"\t\targs[i] = &proto.DynamicValue{\n\t\t\tMsgpack: argValRaw,\n\t\t}\n\t}\n\n\tprotoResp, err := p.client.CallFunction(p.ctx, &proto.CallFunction_Request{\n\t\tName:      r.FunctionName,\n\t\tArguments: args,\n\t})\n\tif err != nil {\n\t\t// functions can only support simple errors, but use our grpcError\n\t\t// diagnostic function to format common problems is a more\n\t\t// user-friendly manner.\n\t\tresp.Err = grpcErr(err).Err()\n\t\treturn resp\n\t}\n\n\tif protoResp.Error != nil {\n\t\tresp.Err = errors.New(protoResp.Error.Text)\n\n\t\t// If this is a problem with a specific argument, we can wrap the error\n\t\t// in a function.ArgError\n\t\tif protoResp.Error.FunctionArgument != nil {\n\t\t\tresp.Err = function.NewArgError(int(*protoResp.Error.FunctionArgument), resp.Err)\n\t\t}\n\n\t\treturn resp\n\t}\n\n\tresultVal, err := decodeDynamicValue(protoResp.Result, funcDecl.ReturnType)\n\tif err != nil {\n\t\tresp.Err = err\n\t\treturn resp\n\t}\n\n\tresp.Result = resultVal\n\treturn resp","sourceCodeStart":1278,"sourceCodeEnd":1314,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/plugin/grpc_provider.go#L1278-L1314","documentation":"Thrown by GRPCProvider.CallFunction (plugin v5) when the provider's CallFunction RPC returned a non-nil `Error` in the response. Provider-defined functions report errors via an Error struct containing a Text field; that text is wrapped as a plain error. If Error.FunctionArgument is set, the error is additionally wrapped in function.NewArgError to point at the offending argument.","triggerScenarios":"Invoking a provider-defined function (the provider_functions feature) whose implementation returned an error — e.g., invalid argument semantics, a runtime failure inside the function.","commonSituations":"Passing a value that passes type-checking but is rejected by the function's runtime logic. A provider function with a bug or that depends on external state. Argument index reported points to which input caused it.","solutions":["Read the FunctionArgument index in the diagnostic — it identifies the offending argument; correct that input.","Upgrade the provider; function implementations mature across versions.","Open an issue with the provider including the exact call and inputs."],"exampleFix":"# before\noutput \"x\" { value = provider::myprov::my_function(\"bad\") }\n\n# after\noutput \"x\" { value = provider::myprov::my_function(\"valid-input\") }","handlingStrategy":"try-catch","validationCode":"# HCL: validate function inputs match documented contract before calling\nlocals { ok = can(provider::myprov::my_function(\"valid\")) }","typeGuard":null,"tryCatchPattern":"# HCL: try() around a provider function call\nlocals { out = try(provider::myprov::my_function(var.input), null) }","preventionTips":["Read the provider function's documented argument constraints before use.","Wrap provider function calls in try() to degrade gracefully.","Pin provider versions so function behavior is stable."],"tags":["terraform","provider","grpc","plugin-v5","provider-functions"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}