{"record":{"id":"8c29730389392564","repo":"charmbracelet/crush","slug":"failed-to-answer-question-batch-status-code-d","errorCode":null,"errorMessage":"failed to answer question batch: status code %d","messagePattern":"failed to answer question batch: status code (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/client/proto.go","lineNumber":706,"sourceCode":"\t}\n\tvar resp proto.PermissionGrantResponse\n\tif err := json.NewDecoder(rsp.Body).Decode(&resp); err != nil {\n\t\treturn false, fmt.Errorf(\"failed to decode grant permission response: %w\", err)\n\t}\n\treturn resp.Resolved, nil\n}\n\n// AnswerQuestionBatch submits answers for a batch question on a\n// workspace. Returns true if this call resolved the pending\n// request, false if already resolved by another caller.\nfunc (c *Client) AnswerQuestionBatch(ctx context.Context, id string, req proto.QuestionAnswer) (bool, error) {\n\trsp, err := c.post(ctx, fmt.Sprintf(\"/workspaces/%s/questions/answer\", id), nil, jsonBody(req), http.Header{\"Content-Type\": []string{\"application/json\"}})\n\tif err != nil {\n\t\treturn false, fmt.Errorf(\"failed to answer 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 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 {","sourceCodeStart":688,"sourceCodeEnd":724,"githubUrl":"https://github.com/charmbracelet/crush/blob/7944b8e52225d8805e31eacbf7ef24856b0dfb7a/internal/client/proto.go#L688-L724","documentation":"AnswerQuestionBatch requires HTTP 200 from /workspaces/{id}/questions/answer. Any non-200 status produces this error with the code embedded. The server rejected the answer submission, so the question remains pending (or was rejected).","triggerScenarios":"POSTing answers with an invalid/expired workspace id (404), insufficient auth (401/403), a QuestionAnswer payload the server rejects (400), or a server fault (5xx).","commonSituations":"Workspace id stale after reconnect; token expiry mid-session; client/server protocol mismatch; server 500 while persisting the answer.","solutions":["Read the status code in the error message and act: re-authenticate on 401/403, refresh the workspace id on 404, check server logs on 5xx.","Validate the QuestionAnswer payload (IDs, format) against the current proto schema before sending.","Re-authenticate if credentials expired.","Retry after fixing the cause; check client/server version compatibility if 400 persists."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Sanity-check the answer payload before sending\nif answer.ID == \"\" || len(answer.Answers) == 0 {\n\treturn errors.New(\"question answer requires an id and at least one answer\")\n}","typeGuard":null,"tryCatchPattern":"_, err := client.AnswerQuestionBatch(ctx, wsID, answer)\nif err != nil && strings.Contains(err.Error(), \"status code\") {\n\tif isAuthStatus(err) { // 401/403\n\t\treturn reauthenticateAndRetry(ctx, wsID, answer)\n\t}\n\treturn fmt.Errorf(\"answering questions on %s: %w\", wsID, err)\n}","preventionTips":["Validate answer payloads against the current proto schema before sending","Refresh expired credentials proactively","Confirm the workspace id is live before answering","Check server logs immediately when 5xx status codes appear"],"tags":["http-client","http-status","questions","api"],"backgroundTag":"http-non-200-response","analyzedSha":"7944b8e52225d8805e31eacbf7ef24856b0dfb7a","analyzedAt":"2026-08-29T12:48:59.079Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}