{"record":{"id":"cad43ed6a28447fd","repo":"gastownhall/beads","slug":"failed-to-parse-batch-create-response-w","errorCode":null,"errorMessage":"failed to parse batch create response: %w","messagePattern":"failed to parse batch create response: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/linear/client.go","lineNumber":1091,"sourceCode":"\t\t\t},\n\t\t}\n\n\t\tdata, err := c.Execute(ctx, req)\n\t\tif err != nil {\n\t\t\tfound, recoverErr := c.recoverAfterAmbiguousBatch(ctx, chunk)\n\t\t\tif recoverErr != nil {\n\t\t\t\treturn allIssues, fmt.Errorf(\"batch create failed and recovery search also failed: %w (batch error: %v)\", recoverErr, err)\n\t\t\t}\n\t\t\tallIssues = append(allIssues, found...)\n\t\t\tif len(found) < len(chunk) {\n\t\t\t\treturn allIssues, fmt.Errorf(\"batch create failed; %d of %d issues unconfirmed (batch error: %v)\", len(chunk)-len(found), len(chunk), err)\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\n\t\tvar batchResp IssueBatchCreateResponse\n\t\tif err := json.Unmarshal(data, &batchResp); err != nil {\n\t\t\treturn allIssues, fmt.Errorf(\"failed to parse batch create response: %w\", err)\n\t\t}\n\n\t\tif !batchResp.IssueBatchCreate.Success {\n\t\t\tfound, recoverErr := c.recoverAfterAmbiguousBatch(ctx, chunk)\n\t\t\tif recoverErr != nil {\n\t\t\t\treturn allIssues, fmt.Errorf(\"batch create unsuccessful and recovery search also failed: %w\", recoverErr)\n\t\t\t}\n\t\t\tallIssues = append(allIssues, found...)\n\t\t\tif len(found) < len(chunk) {\n\t\t\t\treturn allIssues, fmt.Errorf(\"batch create unsuccessful; %d of %d issues unconfirmed\", len(chunk)-len(found), len(chunk))\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\n\t\tallIssues = append(allIssues, batchResp.IssueBatchCreate.Issues...)\n\t}\n\n\treturn allIssues, nil","sourceCodeStart":1073,"sourceCodeEnd":1109,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/linear/client.go#L1073-L1109","documentation":"BatchCreateIssues received a successful HTTP response for the issueBatchCreate mutation but json.Unmarshal could not decode it into IssueBatchCreateResponse. Unlike error-path failures, this branch does NOT run recovery search — the library treats an undecodable success response as a hard parse failure and returns the issues from earlier chunks plus this error.","triggerScenarios":"Calling Client.BatchCreateIssues when Linear returns a body that fails to unmarshal into the expected issues/success envelope: non-JSON payload (proxy HTML page), truncated body, or a schema drift adding/renaming fields the struct cannot accommodate.","commonSituations":"API gateway interference substituting HTML for JSON; SDK/Linear schema version drift; response truncated on unstable networks; mocking transport in tests returning fixtures that don't match IssueBatchCreateResponse.","solutions":["Retry the batch with the same idempotency markers — either the request never landed (safe) or recovery markers let you reconcile.","Log the raw response body to identify whether the payload is HTML, truncated, or shaped differently.","Upgrade the library to a version matching the current Linear GraphQL schema.","Check proxies/gateways between the client and api.linear.app that may rewrite responses."],"exampleFix":"// before\nissues, err := client.BatchCreateIssues(ctx, inputs)\nif err != nil {\n    return err\n}\n// after\nissues, err := client.BatchCreateIssues(ctx, inputs)\nif err != nil {\n    if strings.Contains(err.Error(), \"failed to parse batch create response\") {\n        // response undecodable: retry with same markers; earlier chunks already returned\n        return fmt.Errorf(\"batch response undecodable, retry idempotently: %w\", err)\n    }\n    return err\n}","handlingStrategy":"retry","validationCode":"// No caller-side validation prevents a malformed response; ensure inputs are serializable and the endpoint is reachable\nif len(inputs) == 0 {\n    return nil\n}","typeGuard":"func isBatchParseFailure(err error) bool {\n    return err != nil && strings.Contains(err.Error(), \"failed to parse batch create response\")\n}","tryCatchPattern":"issues, err := client.BatchCreateIssues(ctx, inputs)\nif isBatchParseFailure(err) {\n    // undecodable success response: retry with same markers; earlier chunks already in hand\n    issues2, err2 := client.BatchCreateIssues(ctx, inputs)\n    _ = issues2\n    _ = err2\n}","preventionTips":["Bypass or configure proxies that may substitute non-JSON bodies.","Pin/upgrade the library to match the current Linear GraphQL schema.","Retry idempotently with unchanged markers so re-runs stay safe.","Capture raw response bodies (via a wrapped transport) for post-mortem on parse failures."],"tags":["json","parsing","graphql","batch","network","linear-api"],"backgroundTag":"json-parse-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}