{"record":{"id":"1fca5cd36d3ec413","repo":"chenhg5/cc-connect","slug":"copilot-session-delete-failed-unknown-error","errorCode":null,"errorMessage":"copilot: session.delete failed: unknown error","messagePattern":"copilot: session\\.delete failed: unknown error","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"agent/copilot/copilot.go","lineNumber":411,"sourceCode":"\n\tif delResp.Error != nil {\n\t\t// method-not-found or invalid-request means unsupported\n\t\tif delResp.Error.Code == -32601 || delResp.Error.Code == -32600 {\n\t\t\treturn nil\n\t\t}\n\t\treturn fmt.Errorf(\"copilot: session.delete: %s\", delResp.Error.Message)\n\t}\n\n\tvar result copilotDeleteSessionResponse\n\tif err := json.Unmarshal(delResp.Result, &result); err != nil {\n\t\t// Ignore parse errors - treat as success\n\t\treturn nil\n\t}\n\tif !result.Success {\n\t\tif result.Error != nil {\n\t\t\treturn fmt.Errorf(\"copilot: session.delete failed: %s\", *result.Error)\n\t\t}\n\t\treturn fmt.Errorf(\"copilot: session.delete failed: unknown error\")\n\t}\n\tslog.Info(\"copilot: session deleted\", \"sessionId\", sessionID)\n\treturn nil\n}\n\n// GetSessionHistory implements core.HistoryProvider.\n// Copilot does not expose a history RPC; return empty gracefully.\nfunc (a *Agent) GetSessionHistory(_ context.Context, _ string, _ int) ([]core.HistoryEntry, error) {\n\treturn nil, nil\n}\n\n// CompressCommand implements core.ContextCompressor.\n// Copilot has no built-in compact/compress command.\nfunc (a *Agent) CompressCommand() string { return \"\" }\n\n// ── ProviderSwitcher implementation ──────────────────────────\n\nfunc (a *Agent) SetProviders(providers []core.ProviderConfig) {","sourceCodeStart":393,"sourceCodeEnd":429,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/agent/copilot/copilot.go#L393-L429","documentation":"The session/delete RPC result parsed fine and reported success=false, but no Error detail string was provided in the payload, so the library can only report an unknown failure. It signals the copilot CLI deviated from its expected response contract (success=false must carry an error reason).","triggerScenarios":"DeleteSession receiving copilotDeleteSessionResponse{Success:false, Error:nil} — a CLI build that omits the error field on failure.","commonSituations":"Older or beta copilot CLI versions with incomplete session.delete implementations; third-party/forked CLI binaries not following the documented response shape.","solutions":["Upgrade the copilot CLI to a version that populates the error field on failed deletes","Check copilot CLI logs for the actual failure cause since the response carries none","Treat defensively: re-list sessions to see if the delete actually took effect despite success=false"],"exampleFix":"// before\nif !result.Success {\n    return fmt.Errorf(\"copilot: session.delete failed: unknown error\")\n}\n// after\nif !result.Success {\n    if result.Error != nil { return fmt.Errorf(\"copilot: session.delete failed: %s\", *result.Error) }\n    slog.Warn(\"copilot session.delete reported failure without detail\")\n    return fmt.Errorf(\"copilot: session.delete failed: unknown error\")\n}","handlingStrategy":"fallback","validationCode":"// confirm current state instead of trusting the ambiguous response\nsessions, _ := a.ListSessions(ctx)\nfor _, s := range sessions { if s.ID == sessionID { /* still present */ } }","typeGuard":"func deleteErrKnown(err error) bool { return err != nil && strings.Contains(err.Error(), \"session.delete failed\") }","tryCatchPattern":"if err := a.DeleteSession(ctx, id); deleteErrKnown(err) {\n    if still, _ := sessionExists(a, ctx, id); !still {\n        slog.Info(\"session actually deleted despite unknown failure\")\n    }\n}","preventionTips":["Upgrade the copilot CLI — the no-detail failure usually indicates an old/incomplete implementation","Log the raw RPC result when Success is false to aid diagnosis","Re-verify via ListSessions rather than assuming failure"],"tags":["jsonrpc","copilot","session","unexpected-response"],"backgroundTag":"unexpected-api-response-shape","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}