{"record":{"id":"c2ea5e6ab847d92e","repo":"shareAI-lab/learn-claude-code","slug":"task-subject-cannot-be-empty-c2ea5e","errorCode":null,"errorMessage":"Task subject cannot be empty","messagePattern":"Task subject cannot be empty","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"s15_integrated_harness/code.py","lineNumber":212,"sourceCode":"    blockedBy: list[str]\n    worktree: str | None = None\n\n\ndef _task_path(task_id: str) -> Path:\n    if not isinstance(task_id, str) or not TASK_ID_PATTERN.fullmatch(task_id):\n        raise ValueError(f\"Invalid task ID: {task_id!r}\")\n    path = (TASKS_DIR / f\"{task_id}.json\").resolve()\n    if (not TASKS_ROOT.is_relative_to(WORKDIR.resolve())\n            or not path.is_relative_to(TASKS_ROOT)):\n        raise ValueError(f\"Invalid task ID: {task_id!r}\")\n    return path\n\n\ndef create_task(subject: str, description: str = \"\",\n                blockedBy: list[str] | None = None) -> Task:\n    subject = subject.strip()\n    if not subject:\n        raise ValueError(\"Task subject cannot be empty\")\n    dependencies = list(dict.fromkeys(blockedBy or []))\n    with task_store_lock():\n        for dependency in dependencies:\n            if not _task_path(dependency).is_file():\n                raise ValueError(f\"Dependency not found: {dependency}\")\n        for _ in range(100):\n            task = Task(\n                id=f\"task_{secrets.token_hex(4)}\",\n                subject=subject,\n                description=description,\n                status=\"pending\",\n                owner=None,\n                blockedBy=dependencies,\n            )\n            try:\n                with _task_path(task.id).open(\"x\", encoding=\"utf-8\") as handle:\n                    json.dump(asdict(task), handle, indent=2)\n                return task","sourceCodeStart":194,"sourceCodeEnd":230,"githubUrl":"https://github.com/shareAI-lab/learn-claude-code/blob/985456f4adea6f4df8fbad4112245dbd97444eae/s15_integrated_harness/code.py#L194-L230","documentation":"create_task() strips the subject and refuses to create a task with an empty subject. The subject is the task's primary identifier shown in listings and to teammate agents, so blank subjects are rejected outright rather than defaulted.","triggerScenarios":"Calling create_task(subject=\"\" ), create_task(\"   \"), or passing a subject that is only whitespace. Common when the argument comes from an LLM tool call where the model put the subject in the wrong parameter or omitted it.","commonSituations":"Model fills description but leaves subject blank; a script maps the wrong column/field into subject; whitespace-padded input from a form or CSV.","solutions":["Pass a non-empty, meaningful subject string (it is .strip()ed, so trim whitespace first if you need exact content).","If automating, fall back to a derived subject (e.g. first line of description) instead of an empty string.","Validate subject.strip() on the caller side before invoking the tool."],"exampleFix":"// before\ncreate_task(subject=\"\", description=\"fix login bug\")\n\n// after\ncreate_task(subject=\"Fix login bug\", description=\"fix login bug\")","handlingStrategy":"validation","validationCode":"subject = subject.strip() if isinstance(subject, str) else \"\"\nif not subject:\n    subject = description.strip().splitlines()[0] if description.strip() else None\nif subject:\n    task = create_task(subject, description)","typeGuard":"def is_valid_subject(subject) -> bool:\n    return isinstance(subject, str) and bool(subject.strip())","tryCatchPattern":"try:\n    create_task(subject, description)\nexcept ValueError as e:\n    if \"subject cannot be empty\" in str(e):\n        # prompt the caller/model for a subject; do not default silently\n        raise","preventionTips":["Require a non-empty subject in UI/tool schemas (minLength: 1).","Strip input before submission.","When automating from descriptions, derive subject from the first line."],"tags":["validation","task","input-validation"],"backgroundTag":null,"analyzedSha":"985456f4adea6f4df8fbad4112245dbd97444eae","analyzedAt":"2026-08-14T22:02:26.028Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}