Skip to content

Commit 91d89cb

Browse files
Address PR review comments
- go/session.go: guard against nil PermissionDecision from handler - go/README.md: fix non-compiling permission handler example - python/README.md: fix PermissionDecision* import path Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 0af0478 commit 91d89cb

3 files changed

Lines changed: 15 additions & 5 deletions

File tree

go/README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,8 @@ Provide your own `PermissionHandlerFunc` to inspect each request and apply custo
595595

596596
```go
597597
import (
598+
"fmt"
599+
598600
copilot "github.com/github/copilot-sdk/go"
599601
"github.com/github/copilot-sdk/go/rpc"
600602
)
@@ -605,9 +607,8 @@ session, err := client.CreateSession(context.Background(), &copilot.SessionConfi
605607
// Type-switch on the discriminated PermissionRequest variants to
606608
// access per-kind fields:
607609
if shell, ok := request.(*copilot.PermissionRequestShell); ok {
608-
return &rpc.PermissionDecisionReject{
609-
Feedback: pointer(fmt.Sprintf("Refusing shell: %s", shell.FullCommandText)),
610-
}, nil
610+
feedback := fmt.Sprintf("Refusing shell: %s", shell.FullCommandText)
611+
return &rpc.PermissionDecisionReject{Feedback: &feedback}, nil
611612
}
612613
return &rpc.PermissionDecisionApproveOnce{}, nil
613614
},

go/session.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,6 +1151,15 @@ func (s *Session) executePermissionAndRespond(requestID string, permissionReques
11511151
})
11521152
return
11531153
}
1154+
if decision == nil {
1155+
// Handler returned (nil, nil); treat as user-not-available rather
1156+
// than sending null on the wire.
1157+
s.RPC.Permissions.HandlePendingPermissionRequest(context.Background(), &rpc.PermissionDecisionRequest{
1158+
RequestID: requestID,
1159+
Result: &rpc.PermissionDecisionUserNotAvailable{},
1160+
})
1161+
return
1162+
}
11541163
if _, ok := decision.(*rpc.PermissionDecisionNoResult); ok {
11551164
return
11561165
}

python/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -575,11 +575,11 @@ Provide your own function to inspect each request and apply custom logic (sync o
575575

576576
```python
577577
from copilot import PermissionRequest, PermissionRequestResult
578-
from copilot.generated.session_events import (
578+
from copilot.generated.rpc import (
579579
PermissionDecisionApproveOnce,
580580
PermissionDecisionReject,
581-
PermissionRequestShell,
582581
)
582+
from copilot.generated.session_events import PermissionRequestShell
583583

584584

585585
def on_permission_request(

0 commit comments

Comments
 (0)