{"record":{"id":"abbb7158d36c2ff6","repo":"charmbracelet/crush","slug":"failed-to-cancel-question-batch-w","errorCode":null,"errorMessage":"failed to cancel question batch: %w","messagePattern":"failed to cancel question batch: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/client/proto.go","lineNumber":721,"sourceCode":"\t}\n\tdefer rsp.Body.Close()\n\tif rsp.StatusCode != http.StatusOK {\n\t\treturn false, fmt.Errorf(\"failed to answer question batch: status code %d\", rsp.StatusCode)\n\t}\n\tvar resp proto.QuestionAnswerResponse\n\tif err := json.NewDecoder(rsp.Body).Decode(&resp); err != nil {\n\t\treturn false, fmt.Errorf(\"failed to decode answer question batch response: %w\", err)\n\t}\n\treturn resp.Resolved, nil\n}\n\n// CancelQuestionBatch cancels the pending question batch on a\n// workspace. Returns true if a question was cancelled, false if\n// none was pending.\nfunc (c *Client) CancelQuestionBatch(ctx context.Context, id string) (bool, error) {\n\trsp, err := c.post(ctx, fmt.Sprintf(\"/workspaces/%s/questions/cancel\", id), nil, nil, http.Header{})\n\tif err != nil {\n\t\treturn false, fmt.Errorf(\"failed to cancel question batch: %w\", err)\n\t}\n\tdefer rsp.Body.Close()\n\tif rsp.StatusCode != http.StatusOK {\n\t\treturn false, fmt.Errorf(\"failed to cancel question batch: status code %d\", rsp.StatusCode)\n\t}\n\tvar resp proto.QuestionAnswerResponse\n\tif err := json.NewDecoder(rsp.Body).Decode(&resp); err != nil {\n\t\treturn false, fmt.Errorf(\"failed to decode cancel question batch response: %w\", err)\n\t}\n\treturn resp.Resolved, nil\n}\n\n// SetPermissionsSkipRequests sets the skip-requests flag for a workspace.\nfunc (c *Client) SetPermissionsSkipRequests(ctx context.Context, id string, skip bool) error {\n\trsp, err := c.post(ctx, fmt.Sprintf(\"/workspaces/%s/permissions/skip\", id), nil, jsonBody(proto.PermissionSkipRequest{Skip: skip}), http.Header{\"Content-Type\": []string{\"application/json\"}})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to set permissions skip requests: %w\", err)\n\t}","sourceCodeStart":703,"sourceCodeEnd":739,"githubUrl":"https://github.com/charmbracelet/crush/blob/7944b8e52225d8805e31eacbf7ef24856b0dfb7a/internal/client/proto.go#L703-L739","documentation":"CancelQuestionBatch POSTs to /workspaces/{id}/questions/cancel to cancel a pending question batch. This error wraps transport-level failures from c.post (connection refused, DNS, TLS, context cancellation), meaning the cancel request never reached the server and any pending question remains open.","triggerScenarios":"Calling CancelQuestionBatch while the server is unreachable, the network drops, or the context is cancelled/timed out before the POST completes.","commonSituations":"Cancelling during a server restart; user aborting a prompt while offline; VPN/network transitions; wrong server address in client config.","solutions":["Check server reachability and retry CancelQuestionBatch; a false return simply means nothing was pending.","Verify client base URL/port configuration.","Use a fresh context with an adequate timeout if cancellations time out.","If the question was answered elsewhere, treat the cancel as moot and continue."],"exampleFix":"// before\nok, err := client.CancelQuestionBatch(ctx, wsID)\nif err != nil { panic(err) }\n// after\nok, err := client.CancelQuestionBatch(ctx, wsID)\nif err != nil {\n\tlog.Warn(\"cancel request failed; question may still be pending\", \"err\", err)\n\treturn err\n}\nif !ok { log.Info(\"no pending question to cancel\") }","handlingStrategy":"retry","validationCode":"if wsID == \"\" {\n\treturn errors.New(\"workspace id is required to cancel a question batch\")\n}\nif err := serverReachable(ctx, baseURL); err != nil {\n\treturn fmt.Errorf(\"cannot cancel: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"ok, err := client.CancelQuestionBatch(ctx, wsID)\nif err != nil {\n\t// non-fatal: question may have already been answered/cancelled elsewhere\n\tlog.Warn(\"question cancel failed\", \"err\", err)\n\treturn nil\n}\nif !ok { log.Info(\"no pending question batch\") }","preventionTips":["Treat cancel failures as non-fatal — the question lifecycle is already race-prone","Use a bounded-retry wrapper for cancel calls on flaky networks","Verify server connectivity after restarts before issuing cancels","Keep one source of truth for the workspace id"],"tags":["http-client","network","questions"],"backgroundTag":"http-request-failed","analyzedSha":"7944b8e52225d8805e31eacbf7ef24856b0dfb7a","analyzedAt":"2026-08-29T12:48:59.079Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}