{"record":{"id":"ff1cf460457a8dde","repo":"gastownhall/beads","slug":"failed-to-parse-create-response-w-ff1cf4","errorCode":null,"errorMessage":"failed to parse create response: %w","messagePattern":"failed to parse create response: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/linear/client.go","lineNumber":855,"sourceCode":"\t}\n\treturn input\n}\n\n// CreateIssue creates a new issue in Linear.\nfunc (c *Client) CreateIssue(ctx context.Context, title, description string, priority int, stateID string, labelIDs []string) (*Issue, error) {\n\treq := &GraphQLRequest{\n\t\tQuery:     issueCreateMutation,\n\t\tVariables: map[string]interface{}{\"input\": c.buildIssueCreateInput(title, description, priority, stateID, labelIDs)},\n\t}\n\n\tdata, err := c.Execute(ctx, req)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create issue: %w\", err)\n\t}\n\n\tvar createResp IssueCreateResponse\n\tif err := json.Unmarshal(data, &createResp); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to parse create response: %w\", err)\n\t}\n\n\tif !createResp.IssueCreate.Success {\n\t\treturn nil, fmt.Errorf(\"issue creation reported as unsuccessful\")\n\t}\n\n\treturn &createResp.IssueCreate.Issue, nil\n}\n\n// createIssueSingleAttempt executes the issueCreate mutation exactly once,\n// without the retry loop used by Execute. This is intentional: retrying a\n// mutation that may have already reached Linear risks creating a duplicate.\n// The caller (CreateIssueIdempotent) handles retry safety by re-searching for\n// the idempotency marker after any failure.\nfunc (c *Client) createIssueSingleAttempt(ctx context.Context, title, description string, priority int, stateID string, labelIDs []string) (*Issue, error) {\n\treq := &GraphQLRequest{\n\t\tQuery:     issueCreateMutation,\n\t\tVariables: map[string]interface{}{\"input\": c.buildIssueCreateInput(title, description, priority, stateID, labelIDs)},","sourceCodeStart":837,"sourceCodeEnd":873,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/linear/client.go#L837-L873","documentation":"After the issueCreate mutation succeeds at the transport level, the response is unmarshalled into IssueCreateResponse. This error wraps JSON decoding failures, meaning the HTTP call returned but the body is not the expected `{ issueCreate: { success, issue } }` shape.","triggerScenarios":"Response body deviates from IssueCreateResponse — GraphQL error partial payloads (success field absent → unmarshal type mismatch), proxy HTML bodies with 200 status, endpoint misconfiguration, Linear schema changes to the issueCreate payload.","commonSituations":"Hitting the wrong URL (REST endpoint), intermediary proxies or captive portals, truncated responses, Linear API payload changes.","solutions":["Dump the raw `data` bytes when this error occurs to see the actual body shape.","Confirm c.Endpoint points to https://api.linear.app/graphql.","Surface any GraphQL `errors` array from the response before unmarshalling into IssueCreateResponse.","Update IssueCreateResponse if the Linear issueCreate payload schema changed."],"exampleFix":"// before\nif err := json.Unmarshal(data, &createResp); err != nil {\n    return nil, fmt.Errorf(\"failed to parse create response: %w\", err)\n}\n// after\nif err := json.Unmarshal(data, &createResp); err != nil {\n    return nil, fmt.Errorf(\"failed to parse create response: %w (body: %.200s)\", err, data)\n}","handlingStrategy":"type-guard","validationCode":"// ensure we are talking to the GraphQL endpoint\nif !strings.HasSuffix(client.Endpoint, \"/graphql\") {\n    return errors.New(\"issueCreate requires the Linear GraphQL endpoint\")\n}","typeGuard":"func isSuccessResponse(data []byte) bool {\n    var probe struct {\n        IssueCreate *struct {\n            Success *bool `json:\"success\"`\n        } `json:\"issueCreate\"`\n    }\n    return json.Unmarshal(data, &probe) == nil && probe.IssueCreate != nil && probe.IssueCreate.Success != nil\n}","tryCatchPattern":"issue, err := client.CreateIssue(ctx, title, desc, pri, stateID, labels)\nif err != nil {\n    var typeErr *json.UnmarshalTypeError\n    if errors.As(err, &typeErr) {\n        log.Printf(\"issueCreate response shape changed: %s\", typeErr.Field)\n        return errUnexpectedPayload\n    }\n    return err\n}","preventionTips":["Verify the response Content-Type is application/json before decode.","Keep issueCreate queries matched to a tested Linear schema version.","Log raw bodies on parse errors for debugging.","Add CI tests that decode recorded success payloads."],"tags":["json","unmarshal","linear","schema-mismatch"],"backgroundTag":"schema-validation-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}