Centralize ErrorWithSuggestion wrapping in gRPC interceptor#6759
Centralize ErrorWithSuggestion wrapping in gRPC interceptor#6759
Conversation
Co-authored-by: JeffreyCA <[email protected]>
Co-authored-by: JeffreyCA <[email protected]>
Co-authored-by: JeffreyCA <[email protected]>
|
@copilot can you please revert go.mod changes under |
Co-authored-by: JeffreyCA <[email protected]>
|
/azp run azure-dev - cli |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Azure Dev CLI Install InstructionsInstall scriptsMacOS/Linux
bash: pwsh: WindowsPowerShell install MSI install Standalone Binary
MSI
Documentationlearn.microsoft.com documentationtitle: Azure Developer CLI reference
|
This PR moves
wrapErrorWithSuggestionfromprompt_service.gointo a gRPC unary interceptor inserver.go, eliminating repetitive per-method error wrapping across the prompt service. This ensures all gRPC methods automatically preserveErrorWithSuggestiontext (e.g., "runazd auth login") without requiring each handler to call the wrapper explicitly.Changes
server.go— AddederrorWrappingInterceptor()usinggrpc.ChainUnaryInterceptor(runs beforetokenAuthInterceptor). MovedwrapErrorWithSuggestionhelper here.prompt_service.go— Removed 5 call-site usages ofwrapErrorWithSuggestionand the function itself; handlers now return errors directly.prompt_service_test.go— ExtractedsetupTestServerhelper for end-to-end gRPC tests. UpdatedErrorWithSuggestiontests to exercise the full interceptor pipeline via a real gRPC client instead of calling the service directly.server_test.go— Added unit tests forwrapErrorWithSuggestion(nil, plain error, direct and wrappedErrorWithSuggestion).Motivation
Previously, every prompt service method that could surface auth errors needed to individually call
wrapErrorWithSuggestion. This was easy to miss when adding new methods. The interceptor applies the wrapping uniformly across all gRPC endpoints.✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.