Skip to content

Commit 741c7bc

Browse files
authored
fix: improve error handling in GitHub Copilot provider (sipeed#919)
- Fix ignored error from SendAndWait call - Improve error message for unimplemented stdio mode with helpful guidance - Add TODO comment with reference link for future stdio implementation
1 parent 3dddc3d commit 741c7bc

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

pkg/providers/github_copilot_provider.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ func NewGitHubCopilotProvider(uri string, connectMode string, model string) (*Gi
2626

2727
switch connectMode {
2828
case "stdio":
29-
// TODO:
30-
return nil, fmt.Errorf("stdio mode not implemented")
29+
// TODO: Implement stdio mode for GitHub Copilot provider
30+
// See https://github.com/github/copilot-sdk/blob/main/docs/getting-started.md for details
31+
return nil, fmt.Errorf("stdio mode not implemented for GitHub Copilot provider; please use 'grpc' mode instead")
3132
case "grpc":
3233
client := copilot.NewClient(&copilot.ClientOptions{
3334
CLIUrl: uri,
@@ -100,9 +101,12 @@ func (p *GitHubCopilotProvider) Chat(
100101
return nil, fmt.Errorf("provider closed")
101102
}
102103

103-
resp, _ := session.SendAndWait(ctx, copilot.MessageOptions{
104+
resp, err := session.SendAndWait(ctx, copilot.MessageOptions{
104105
Prompt: string(fullcontent),
105106
})
107+
if err != nil {
108+
return nil, fmt.Errorf("failed to send message to copilot: %w", err)
109+
}
106110

107111
if resp == nil {
108112
return nil, fmt.Errorf("empty response from copilot")

0 commit comments

Comments
 (0)