charmbracelet/crush · error
failed to cancel question batch: %w
Error message
failed to cancel question batch: %w
What it means
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.
Source
Thrown at internal/client/proto.go:721
}
defer rsp.Body.Close()
if rsp.StatusCode != http.StatusOK {
return false, fmt.Errorf("failed to answer question batch: status code %d", rsp.StatusCode)
}
var resp proto.QuestionAnswerResponse
if err := json.NewDecoder(rsp.Body).Decode(&resp); err != nil {
return false, fmt.Errorf("failed to decode answer question batch response: %w", err)
}
return resp.Resolved, nil
}
// CancelQuestionBatch cancels the pending question batch on a
// workspace. Returns true if a question was cancelled, false if
// none was pending.
func (c *Client) CancelQuestionBatch(ctx context.Context, id string) (bool, error) {
rsp, err := c.post(ctx, fmt.Sprintf("/workspaces/%s/questions/cancel", id), nil, nil, http.Header{})
if err != nil {
return false, fmt.Errorf("failed to cancel question batch: %w", err)
}
defer rsp.Body.Close()
if rsp.StatusCode != http.StatusOK {
return false, fmt.Errorf("failed to cancel question batch: status code %d", rsp.StatusCode)
}
var resp proto.QuestionAnswerResponse
if err := json.NewDecoder(rsp.Body).Decode(&resp); err != nil {
return false, fmt.Errorf("failed to decode cancel question batch response: %w", err)
}
return resp.Resolved, nil
}
// SetPermissionsSkipRequests sets the skip-requests flag for a workspace.
func (c *Client) SetPermissionsSkipRequests(ctx context.Context, id string, skip bool) error {
rsp, err := c.post(ctx, fmt.Sprintf("/workspaces/%s/permissions/skip", id), nil, jsonBody(proto.PermissionSkipRequest{Skip: skip}), http.Header{"Content-Type": []string{"application/json"}})
if err != nil {
return fmt.Errorf("failed to set permissions skip requests: %w", err)
}View on GitHub (pinned to 7944b8e522)
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.
Example fix
// before
ok, err := client.CancelQuestionBatch(ctx, wsID)
if err != nil { panic(err) }
// after
ok, err := client.CancelQuestionBatch(ctx, wsID)
if err != nil {
log.Warn("cancel request failed; question may still be pending", "err", err)
return err
}
if !ok { log.Info("no pending question to cancel") } Defensive patterns
Strategy: retry
Validate before calling
if wsID == "" {
return errors.New("workspace id is required to cancel a question batch")
}
if err := serverReachable(ctx, baseURL); err != nil {
return fmt.Errorf("cannot cancel: %w", err)
} Try / catch
ok, err := client.CancelQuestionBatch(ctx, wsID)
if err != nil {
// non-fatal: question may have already been answered/cancelled elsewhere
log.Warn("question cancel failed", "err", err)
return nil
}
if !ok { log.Info("no pending question batch") } Prevention
- 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
When it happens
Trigger: Calling CancelQuestionBatch while the server is unreachable, the network drops, or the context is cancelled/timed out before the POST completes.
Common situations: Cancelling during a server restart; user aborting a prompt while offline; VPN/network transitions; wrong server address in client config.
Understand the failure class
Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.
Related errors
- failed to answer question batch: %w
- failed to make request: %w
- failed to refresh OAuth token: %w
- failed to check project init: %w
- failed to mark project initialized: %w
AI-assisted analysis of charmbracelet/crush@7944b8e522 (2026-08-29).
Data as JSON: /api/errors/abbb7158d36c2ff6.
Report an issue: GitHub.