{"record":{"id":"89ac686d348f7eea","repo":"affaan-m/ECC","slug":"missing-title-for-a-new-work-item","errorCode":null,"errorMessage":"Missing --title for a new work item.","messagePattern":"Missing --title for a new work item\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/work-items.js","lineNumber":325,"sourceCode":"    repo,\n    syncedAt,\n    prCount: prs.length,\n    issueCount: issues.length,\n    closedCount: closedItems.length,\n    items,\n    closedItems\n  };\n}\n\nfunction buildUpsertPayload(options, existing = null) {\n  const id = resolveWorkItemId(options);\n  if (!id) {\n    throw new Error('Missing work item id. Pass <id> or --id <id>.');\n  }\n\n  const title = options.title ?? (existing && existing.title);\n  if (!title) {\n    throw new Error('Missing --title for a new work item.');\n  }\n\n  return {\n    id,\n    source: options.source ?? (existing && existing.source) ?? 'manual',\n    sourceId: options.sourceId ?? (existing && existing.sourceId) ?? null,\n    title,\n    status: options.status ?? (existing && existing.status) ?? 'open',\n    priority: options.priority ?? (existing && existing.priority) ?? null,\n    url: options.url ?? (existing && existing.url) ?? null,\n    owner: options.owner ?? (existing && existing.owner) ?? null,\n    repoRoot: options.repoRoot ?? (existing && existing.repoRoot) ?? process.cwd(),\n    sessionId: options.sessionId ?? (existing && existing.sessionId) ?? null,\n    metadata: options.metadataJson !== undefined ? parseMetadataJson(options.metadataJson) : ((existing && existing.metadata) ?? null),\n    createdAt: existing ? existing.createdAt : undefined,\n    updatedAt: new Date().toISOString()\n  };\n}","sourceCodeStart":307,"sourceCodeEnd":343,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/work-items.js#L307-L343","documentation":"Thrown by buildUpsertPayload() when a title cannot be resolved. The title comes from options.title or, only when updating an existing item, existing.title. So a brand-new item (existing is null) with no --title has nothing to store and is rejected. This is intentionally separate from the id check so the error message points at the actually missing field.","triggerScenarios":"Creating a new work item without --title: `node scripts/work-items.js upsert my-item` with no title flag and no existing item for that id. Note that when an item already exists, the missing flag is tolerated and the stored title is reused.","commonSituations":"Running upsert to 'just set status' on an id you expect to exist but does not (so existing is null and there is no title fallback); copying a close-style invocation into upsert; CI job that sets --status but forgets --title on first run.","solutions":["Add --title when creating a new item: `upsert my-item --title \"...\"`.","If you intended to update an existing item, first verify the id exists with `show <id>`; a typo in the id makes existing null and forces this error.","When scripting idempotent creates, always pass --title so the first run (insert) and later runs (update) both succeed."],"exampleFix":"// before\nnode scripts/work-items.js upsert refactor-state-store\n\n// after\nnode scripts/work-items.js upsert refactor-state-store --title \"Refactor state store\"","handlingStrategy":"validation","validationCode":"function ensureUpsertTitle(options, existing) {\n  const title = options.title || (existing && existing.title);\n  if (!title) throw new Error('upsert of a new item needs --title');\n  return title;\n}\n// call: ensureUpsertTitle(options, store.getWorkItemById(id))","typeGuard":"function hasUpsertTitle(options, existing) {\n  return Boolean(options && (options.title || (existing && existing.title)));\n}","tryCatchPattern":null,"preventionTips":["Always pass --title when creating; only omit it when you know the item exists.","Before upserting, run `show <id>` to confirm existence if you plan to rely on the stored title.","Make CI idempotent by always passing both --id and --title."],"tags":["cli","validation","missing-argument","upsert","title"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}