{"record":{"id":"73b9309537da4054","repo":"gastownhall/beads","slug":"work-item-creation-failed-s","errorCode":null,"errorMessage":"work item creation failed: %s","messagePattern":"work item creation failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/gitlab/client.go","lineNumber":627,"sourceCode":"\tvar resp struct {\n\t\tWorkItemCreate struct {\n\t\t\tErrors   []string `json:\"errors\"`\n\t\t\tWorkItem *struct {\n\t\t\t\tID     string `json:\"id\"`\n\t\t\t\tIID    string `json:\"iid\"`\n\t\t\t\tTitle  string `json:\"title\"`\n\t\t\t\tWebURL string `json:\"webUrl\"`\n\t\t\t\tType   struct {\n\t\t\t\t\tName string `json:\"name\"`\n\t\t\t\t} `json:\"workItemType\"`\n\t\t\t} `json:\"workItem\"`\n\t\t} `json:\"workItemCreate\"`\n\t}\n\tif err := json.Unmarshal(data, &resp); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to parse work item response: %w\", err)\n\t}\n\tif len(resp.WorkItemCreate.Errors) > 0 {\n\t\treturn nil, fmt.Errorf(\"work item creation failed: %s\", resp.WorkItemCreate.Errors[0])\n\t}\n\tif resp.WorkItemCreate.WorkItem == nil {\n\t\treturn nil, fmt.Errorf(\"work item creation returned nil\")\n\t}\n\n\twi := resp.WorkItemCreate.WorkItem\n\treturn &WorkItem{\n\t\tID:    wi.ID,\n\t\tIID:   wi.IID,\n\t\tTitle: wi.Title,\n\t\tType:  wi.Type.Name,\n\t}, nil\n}\n\n// GetWorkItemGID looks up the global ID of a work item by its project-scoped IID.\nfunc (c *Client) GetWorkItemGID(ctx context.Context, projectPath string, iid int) (string, error) {\n\tquery := fmt.Sprintf(`{\n\t\tproject(fullPath: %q) {","sourceCodeStart":609,"sourceCodeEnd":645,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/gitlab/client.go#L609-L645","documentation":"The workItemCreate mutation executed and returned mutation-level errors in resp.WorkItemCreate.Errors. This is GitLab's business-level rejection of the work item creation (validation, permissions, bad inputs), surfaced with the first error's text.","triggerScenarios":"Calling CreateTaskWorkItem with an invalid title/description, a nonexistent or unauthorized project/namespace, a workItemTypeID that doesn't exist on the instance, or missing widget inputs the mutation requires.","commonSituations":"A stale cached workItemTypeID after a GitLab upgrade changed type IDs; creating tasks in a project where the token's user lacks Developer+ role; violating title length or description validation rules; using a group ID where a project ID is required.","solutions":["Read the surfaced error string — GitLab states exactly which input or permission failed.","Re-fetch a fresh workItemTypeID via getTaskWorkItemTypeID instead of caching it across upgrades.","Verify the token's user has at least Developer role on the target project.","Validate inputs (title non-empty, valid project path) before calling the mutation."],"exampleFix":"// before: caching type ID across versions\nworkItemTypeID := cachedTypeID // stale after upgrade\n// after\nworkItemTypeID, err := client.getTaskWorkItemTypeID(ctx)\nif err != nil {\n    return nil, err\n}","handlingStrategy":"validation","validationCode":"// pre-flight: verify project access and fresh type ID\nif _, err := client.GetProject(ctx, projectPath); err != nil {\n    return fmt.Errorf(\"cannot access project %s: %w\", projectPath, err)\n}\ntypeID, err := client.getTaskWorkItemTypeID(ctx)\nif err != nil {\n    return err\n}","typeGuard":null,"tryCatchPattern":"item, err := client.CreateTaskWorkItem(ctx, req)\nif err != nil {\n    if strings.Contains(err.Error(), \"work item creation failed\") {\n        // mutation-level rejection: fix the input or permissions named in the message\n    }\n    return err\n}","preventionTips":["Never cache workItemTypeID across GitLab upgrades; fetch it per session.","Ensure the token's user has Developer+ role on the target project.","Validate title/description against GitLab's limits before calling."],"tags":["gitlab","graphql","mutation","validation","permissions"],"backgroundTag":"graphql-mutation-error","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}