rpcperms+lncli: return gRPC status codes from RPC state interceptor#10945
rpcperms+lncli: return gRPC status codes from RPC state interceptor#10945kpshukla wants to merge 1 commit into
Conversation
The checkRPCState function previously returned plain Go errors which gRPC forwarded to clients as codes.Unknown. Callers were forced to do brittle string matching against the error message to identify the cause. Replace each plain error return with a status.Error carrying a semantically correct code: - ErrWaitingToStart -> codes.Unavailable - ErrRPCStarting -> codes.Unavailable - ErrNoWallet -> codes.FailedPrecondition - ErrWalletLocked -> codes.FailedPrecondition - ErrWalletUnlocked -> codes.FailedPrecondition - unknown state -> codes.Unknown The error message text is preserved in every case so existing string-match code keeps working. Update the two call-sites in lncli that checked codes.Unknown to use the correct codes.FailedPrecondition instead. Fixes lightningnetwork#5586 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
🟡 PR Severity: MEDIUM
🟡 Medium (2 files)
🟢 Low (2 files)
AnalysisThe highest-severity files touched are The change itself is narrowly scoped: it maps existing plain errors in the To override, add a |
Summary
Fixes #5586
The
checkRPCStateinterceptor previously returned plain Go errors, which gRPC forwarded to clients ascodes.Unknown. Callers (includinglncli) were forced to do brittle string matching against the error message to determine the cause.This PR replaces each plain error return with a
status.Errorcarrying a semantically correct gRPC code, while keeping the error message text identical to preserve any existing string-match code:codes.Unknowncodes.Unavailablecodes.Unknowncodes.Unavailablecodes.Unknowncodes.FailedPreconditioncodes.Unknowncodes.FailedPreconditioncodes.Unknowncodes.FailedPreconditioncodes.Unknowncodes.Unknown(unchanged)The two
lnclicall-sites incmd/commands/commands.gothat checkedcodes.Unknownare updated to usecodes.FailedPrecondition.Test plan
TestCheckRPCStateGRPCCodescovers all RPC states and server types (10 subtests, all pass)rpcpermstests still passmake installcompiles cleanly🤖 Generated with Claude Code