fix(lambda/grpc): code function-returned errors as FailedPrecondition #970
All Vouch review confidence checks passed
Residual risk 0.26 = Change Risk (0.47) × (1 − Review Confidence (0.45)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.47 · 274 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.336
Real PR Conversation Timeline
1 comments
"Review active on #970"
general
weight: 0.35
arreyder
Problem
When the lambda gRPC transport invokes a function successfully but the function's own code returns an error (
invokeResp.FunctionErrorset),RoundTripreturned a barefmt.Errorf. That surfaces as gRPCcodes.Unknown, and our otel pipeline countsUnknownas a span error / HTTP 5xx.At low call volume this trips the 99.99% failure-rate monitor on be-temporal-lambda-manager — a handful of function-application faults (e.g. a connector that exits
Unhandledduring init, or a function whose startup config fetch is rejected) pages even though nothing on the server is broken.Fix
Recode both return paths inside the
if invokeResp.FunctionError != nilblock from bare error →status.Errorf(codes.FailedPrecondition, ...). A function-returned error is a caller/function-state fault, not a server fault, soFailedPrecondition(4xx, uncounted) is the correct code. The message text is preserved.Unchanged on purpose:
Unavailable, function timeout →DeadlineExceeded.failed to invoke lambda function) and marshal/unmarshal paths — genuine infra/our-bug faults that stay counted.No retry-behavior change:
pkg/retryonly retriesUnavailable/DeadlineExceeded.Unknownwas never retried, and neither isFailedPrecondition— so recoding is behavior-preserving for retries. (The connector-side Hello retry classifier,isRetryableHelloError, is the opposite direction — connector→c1api over a normal dial — and never sees these errors.)Test
Adds a
lambdaInvokerinterface seam (subset of*lambda.Client; the concrete client still satisfies it, no caller changes) soRoundTripis unit-testable, plus a regression test assertingFailedPreconditionon both function-error paths (meaningful-logs and no-meaningful-logs).go vetclean;go test ./pkg/lambda/grpc/passes.Downstream
c1 picks this up on the next baton-sdk release + re-vendor;
be-temporal-lambda-manager's existingclassifyLambdaErrorpass-through then carries theFailedPreconditioncode through unchanged.🤖 Generated with Claude Code