{"record":{"id":"a9ef8b9e7eca8fd7","repo":"HKUDS/Vibe-Trading","slug":"source-prompt-is-required","errorCode":null,"errorMessage":"source.prompt is required","messagePattern":"source\\.prompt is required","errorType":"validation","errorClass":"ValueError","httpStatus":400,"severity":"error","filePath":"agent/src/scheduled_research/service.py","lineNumber":138,"sourceCode":"    now = int(time.time() * 1000) if now_ms is None else now_ms\n    title = str(draft.get(\"title\") or \"\").strip()\n    if not title:\n        raise ValueError(\"title is required\")\n    source = draft.get(\"source\")\n    schedule_spec = draft.get(\"schedule\")\n    delivery_spec = draft.get(\"delivery\") or {\"mode\": \"in_app\"}\n    if not isinstance(source, Mapping) or not isinstance(schedule_spec, Mapping):\n        raise ValueError(\"source and schedule must be objects\")\n    if not isinstance(delivery_spec, Mapping):\n        raise ValueError(\"delivery must be an object\")\n\n    source_type = str(source.get(\"kind\") or \"prompt\")\n    playbook_slug = None\n    config: dict[str, Any] = {}\n    if source_type == \"prompt\":\n        prompt = str(source.get(\"prompt\") or \"\").strip()\n        if not prompt:\n            raise ValueError(\"source.prompt is required\")\n    elif source_type == \"playbook\":\n        playbook_slug = str(source.get(\"playbook_slug\") or \"\").strip()\n        if not playbook_slug:\n            raise ValueError(\"source.playbook_slug is required\")\n        playbook = get_playbook(playbook_slug)\n        variables = source.get(\"variables\") or {}\n        if not isinstance(variables, Mapping):\n            raise ValueError(\"source.variables must be an object\")\n        prompt = playbook.render(variables)\n        config[\"playbook\"] = playbook_slug\n    else:\n        raise ValueError(\"source.kind must be 'prompt' or 'playbook'\")\n\n    expression = str(schedule_spec.get(\"expression\") or \"\").strip()\n    timezone = schedule_spec.get(\"timezone\")\n    validate_schedule(expression)\n    if is_interval_schedule(expression):\n        validate_timezone_shape(timezone)","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/scheduled_research/service.py#L120-L156","documentation":"When draft.source.kind is 'prompt' (the default), source.prompt must be a non-empty string after stripping. This is the instruction the scheduler will run periodically.","triggerScenarios":"source={\"kind\":\"prompt\"} with prompt omitted, empty, or whitespace; kind defaulted to 'prompt' because it was absent while prompt was also absent.","commonSituations":"Minimal drafts that only set schedule; UI where the prompt textarea is optional; templates with an empty prompt slot.","solutions":["Set source.prompt to the research instruction text","If you meant a playbook, set kind='playbook' and playbook_slug instead","Require the prompt field in client validation when kind is prompt"],"exampleFix":"// before\n{\"source\": {\"kind\": \"prompt\"}}\n// after\n{\"source\": {\"kind\": \"prompt\", \"prompt\": \"Summarize AI news\"}}","handlingStrategy":"validation","validationCode":"src = draft.get(\"source\", {})\nif str(src.get(\"kind\") or \"prompt\") == \"prompt\":\n    assert str(src.get(\"prompt\") or \"\").strip(), \"source.prompt is required\"","typeGuard":"def prompt_source_valid(src: dict) -> bool:\n    return str(src.get(\"kind\") or \"prompt\") != \"prompt\" or bool(str(src.get(\"prompt\") or \"\").strip())","tryCatchPattern":"try:\n    propose_create(draft)\nexcept ValueError as e:\n    require_prompt_field() if \"source.prompt\" in str(e) else raise_","preventionTips":["Require prompt text in the creation form when kind is prompt","Default missing prompts to a meaningful template rather than empty"],"tags":["scheduled-research","validation","prompt","required-field"],"backgroundTag":"missing-required-field","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}