{"record":{"id":"d79ba3b20c08a0e8","repo":"github/copilot-sdk","slug":"failed-to-unmarshal-delete-response-w","errorCode":null,"errorMessage":"failed to unmarshal delete response: %w","messagePattern":"failed to unmarshal delete response: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/client.go","lineNumber":1618,"sourceCode":"//\tif err := client.DeleteSession(context.Background(), \"session-123\"); err != nil {\n//\t    log.Fatal(err)\n//\t}\nfunc (c *Client) DeleteSession(ctx context.Context, sessionID string) error {\n\tunlockSession := c.lockSessionOperation(sessionID)\n\tdefer unlockSession()\n\n\tif err := c.ensureConnected(ctx); err != nil {\n\t\treturn err\n\t}\n\n\tresult, err := c.client.Request(ctx, \"session.delete\", deleteSessionRequest{SessionID: sessionID})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvar response deleteSessionResponse\n\tif err := json.Unmarshal(result, &response); err != nil {\n\t\treturn fmt.Errorf(\"failed to unmarshal delete response: %w\", err)\n\t}\n\n\tif !response.Success {\n\t\terrorMsg := \"unknown error\"\n\t\tif response.Error != nil {\n\t\t\terrorMsg = *response.Error\n\t\t}\n\t\treturn fmt.Errorf(\"failed to delete session %s: %s\", sessionID, errorMsg)\n\t}\n\n\t// Remove from local sessions map if present\n\tc.sessionsMux.Lock()\n\tsession := c.sessions[sessionID]\n\tdelete(c.sessions, sessionID)\n\tc.sessionsMux.Unlock()\n\tif session != nil {\n\t\tsession.releaseGitHubTokenProviderRegistration()\n\t}","sourceCodeStart":1600,"sourceCodeEnd":1636,"githubUrl":"https://github.com/github/copilot-sdk/blob/cd8cf15dc3f9e762615790aaed0a771a0f392755/go/client.go#L1600-L1636","documentation":"DeleteSession returns this error when the 'session.delete' result cannot be unmarshalled into deleteSessionResponse. The backend acknowledged the call but its response body was not the expected {success, error} object.","triggerScenarios":"Calling DeleteSession when the backend returns a malformed or unexpected delete confirmation payload.","commonSituations":"Version mismatch between client and backend; backend crashed mid-response leaving a truncated payload; middleware rewriting the response.","solutions":["Capture the raw result bytes and validate the expected {success, error} shape","Update client library and backend to the same version","Retry the delete; if it recurs, inspect backend logs for the failing session delete","Check whether a proxy/IPC layer is corrupting the response"],"exampleFix":"// before\nerr := client.DeleteSession(ctx, sessionID)\n// after\nerr := client.DeleteSession(ctx, sessionID)\nif err != nil && strings.Contains(err.Error(), \"unmarshal delete response\") {\n    // fall back: verify via ListSessions whether the session is gone\n}","handlingStrategy":"try-catch","validationCode":"if sessionID == \"\" {\n    return fmt.Errorf(\"DeleteSession: empty sessionID\")\n}","typeGuard":"func isDeleteUnmarshalError(err error) bool {\n    return strings.Contains(err.Error(), \"unmarshal delete response\")\n}","tryCatchPattern":"if err := client.DeleteSession(ctx, id); err != nil {\n    if isDeleteUnmarshalError(err) {\n        // verify deletion via ListSessions before retrying\n        return fmt.Errorf(\"delete ack undecodable: %w\", err)\n    }\n    return err\n}","preventionTips":["Keep client/backend versions aligned","Confirm deletion independently (ListSessions) rather than trusting a single response","Log raw delete responses during upgrades"],"tags":["json","unmarshal","delete-session"],"backgroundTag":"json-unmarshal-failed","analyzedSha":"cd8cf15dc3f9e762615790aaed0a771a0f392755","analyzedAt":"2026-09-09T18:32:31.973Z","contentChangedAt":"2026-09-09T18:32:31.973Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}