{"record":{"id":"15d1f224d2e81772","repo":"charmbracelet/crush","slug":"failed-to-decode-answer-question-batch-response","errorCode":null,"errorMessage":"failed to decode answer question batch response: %w","messagePattern":"failed to decode answer question batch response: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/client/proto.go","lineNumber":710,"sourceCode":"\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 {\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 {","sourceCodeStart":692,"sourceCodeEnd":728,"githubUrl":"https://github.com/charmbracelet/crush/blob/7944b8e52225d8805e31eacbf7ef24856b0dfb7a/internal/client/proto.go#L692-L728","documentation":"On a 200 response, AnswerQuestionBatch decodes the body into proto.QuestionAnswerResponse to learn whether this call resolved the question. Decode failure (empty body, HTML from a proxy, schema mismatch) yields this error, leaving the Resolved outcome unknown.","triggerScenarios":"Server returns 200 with empty/malformed JSON; a proxy rewrites the body; the server's response schema differs from proto.QuestionAnswerResponse due to version skew.","commonSituations":"Gateway HTML interstitial with 200; partial/truncated response on flaky connections; server upgraded to a new response format while client is old.","solutions":["Capture the raw response body (curl or logging proxy) to identify the malformed payload.","Align client and server versions so the response struct matches.","Inspect intermediary proxies/gateways that may alter response bodies.","Retry; if reproducible, file a server bug with a wire dump."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":"func isAnswerDecodeError(err error) bool {\n\treturn err != nil && strings.Contains(err.Error(), \"failed to decode answer question batch response\")\n}","tryCatchPattern":"resolved, err := client.AnswerQuestionBatch(ctx, wsID, answer)\nif isAnswerDecodeError(err) {\n\t// outcome unknown; retry once — Resolved flag prevents double resolution\n\treturn retryAnswerBatch(ctx, wsID, answer, 1)\n}","preventionTips":["Match client/server versions to keep response schemas aligned","Log raw bodies when decode fails to spot proxy interference","Retry decode failures once before giving up","Watch for gateways returning HTML with 200 status"],"tags":["json","decoding","http-client","questions"],"backgroundTag":"json-decode-failed","analyzedSha":"7944b8e52225d8805e31eacbf7ef24856b0dfb7a","analyzedAt":"2026-08-29T12:48:59.079Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}