{"record":{"id":"fcb1fa25e7b3e9dd","repo":"hashicorp/terraform","slug":"protoresp-error-text-fcb1fa","errorCode":null,"errorMessage":"${protoResp.Error.Text}","messagePattern":"\\$\\{protoResp\\.Error\\.Text\\}","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/plugin6/grpc_provider.go","lineNumber":1304,"sourceCode":"\t\targs[i] = &proto6.DynamicValue{\n\t\t\tMsgpack: argValRaw,\n\t\t}\n\t}\n\n\tprotoResp, err := p.client.CallFunction(p.ctx, &proto6.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":1286,"sourceCodeEnd":1322,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/plugin6/grpc_provider.go#L1286-L1322","documentation":"Thrown by GRPCProvider.CallFunction (plugin v6) when CallFunction RPC returned a non-nil `Error` in the response. Provider-defined functions report errors via Error.Text; that text is wrapped as a plain error and, if FunctionArgument is set, additionally wrapped in function.NewArgError to identify the offending argument. Identical semantics to the v5 path.","triggerScenarios":"Calling a v6 provider-defined function whose implementation returned a runtime error or rejected an argument's value.","commonSituations":"A function argument that passes type-checking but fails value validation inside the function. A buggy provider function or one depending on unavailable external state.","solutions":["Use the reported FunctionArgument index to identify and fix the offending argument.","Upgrade the provider; provider function behavior stabilizes across releases.","Report the issue to the provider maintainer with the call and inputs."],"exampleFix":"# before\noutput \"x\" { value = provider::myprov::compute(\"bad\") }\n\n# after\noutput \"x\" { value = provider::myprov::compute(\"valid\") }","handlingStrategy":"try-catch","validationCode":"# HCL: sanity-check inputs before the call\nlocals { ok = can(provider::myprov::compute(\"valid\")) }","typeGuard":null,"tryCatchPattern":"# HCL: try() around the v6 provider function\nlocals { out = try(provider::myprov::compute(var.input), null) }","preventionTips":["Read the provider function's documented argument contract.","Wrap provider function calls in try().","Pin provider versions for stable function behavior."],"tags":["terraform","provider","grpc","plugin-v6","provider-functions"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}