{"record":{"id":"8bf26e9db1ebf27c","repo":"gastownhall/beads","slug":"failed-to-parse-create-response-w-8bf26e","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/gitlab/client.go","lineNumber":358,"sourceCode":"// CreateIssue creates a new issue in GitLab.\nfunc (c *Client) CreateIssue(ctx context.Context, title, description string, labels []string) (*Issue, error) {\n\tbody := map[string]interface{}{\n\t\t\"title\":       title,\n\t\t\"description\": description,\n\t}\n\tif len(labels) > 0 {\n\t\tbody[\"labels\"] = labels\n\t}\n\n\turlStr := c.buildURL(\"/projects/\"+c.projectPath()+\"/issues\", nil)\n\trespBody, _, err := c.doRequest(ctx, http.MethodPost, urlStr, body)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create issue: %w\", err)\n\t}\n\n\tvar issue Issue\n\tif err := json.Unmarshal(respBody, &issue); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to parse create response: %w\", err)\n\t}\n\n\treturn &issue, nil\n}\n\n// UpdateIssue updates an existing issue in GitLab.\nfunc (c *Client) UpdateIssue(ctx context.Context, iid int, updates map[string]interface{}) (*Issue, error) {\n\turlStr := c.buildURL(\"/projects/\"+c.projectPath()+\"/issues/\"+strconv.Itoa(iid), nil)\n\trespBody, _, err := c.doRequest(ctx, http.MethodPut, urlStr, updates)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to update issue: %w\", err)\n\t}\n\n\tvar issue Issue\n\tif err := json.Unmarshal(respBody, &issue); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to parse update response: %w\", err)\n\t}\n","sourceCodeStart":340,"sourceCodeEnd":376,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/gitlab/client.go#L340-L376","documentation":"CreateIssue received a response it could not decode into a single Issue object. The HTTP call succeeded but the body was not the expected JSON issue payload.","triggerScenarios":"POST /projects/:id/issues returns a non-issue JSON body — e.g. an error object (as JSON with 200 from a proxy), an HTML page, or GitLab schema drift making a field's type incompatible with the Issue struct.","commonSituations":"API gateways returning JSON error envelopes, GitLab upgrades changing field types, or pointing the client at a non-GitLab endpoint that echoes JSON.","solutions":["Inspect the raw response body (log respBody on parse failure) and the wrapped Unmarshal error","Compare the failing field against the Issue struct and update the library or struct for your GitLab version","Verify the endpoint is the real GitLab API (no interception)","Pin library version to your server's GitLab version"],"exampleFix":"// before\nissue, err := client.CreateIssue(ctx, title, desc, labels)\n// after\nissue, err := client.CreateIssue(ctx, title, desc, labels)\nif err != nil {\n\tlog.Printf(\"create failed (resp body may differ from Issue schema): %v\", err)\n}","handlingStrategy":"try-catch","validationCode":"resp, _ := http.Post(baseURL+\"/api/v4/projects/\"+proj+\"/issues\", \"application/json\", bodyReader)\nct := resp.Header.Get(\"Content-Type\")\nif !strings.Contains(ct, \"application/json\") {\n\treturn fmt.Errorf(\"unexpected content type %q; endpoint may be intercepted\", ct)\n}","typeGuard":"func isParseCreateErr(err error) bool {\n\treturn strings.Contains(err.Error(), \"failed to parse create response\")\n}","tryCatchPattern":"issue, err := client.CreateIssue(ctx, title, desc, labels)\nif err != nil {\n\tif isParseCreateErr(err) {\n\t\tlog.Printf(\"create succeeded at server? verify manually; response unparseable: %v\", err)\n\t}\n\treturn err\n}","preventionTips":["Remove API-rewriting proxies/gateways from the path","Keep library and GitLab server versions compatible","On parse failure, check the server for duplicate issues before retrying (the create may have succeeded)","Log raw response bodies for post-mortem"],"tags":["gitlab","json","network"],"backgroundTag":"json-unmarshal-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}