{"record":{"id":"bd1c2313e68c498c","repo":"nanocoai/nanoclaw","slug":"prompt-is-required-bd1c23","errorCode":null,"errorMessage":"--prompt is required","messagePattern":"--prompt is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/modules/scheduling/create.ts","lineNumber":112,"sourceCode":"  if (fires > MAX_DAILY_FIRES) throw new Error(RECURRENCE_LIMIT_WARNING);\n}\n\n/**\n * Validate task semantics and derive its first run without writing anything.\n * `timezone` grounds wall-clock interpretation (cron grid, naive\n * --process-after) — pass the owning group's effective timezone\n * (`resolveGroupTimezone`); it defaults to the install-global one.\n */\nexport function prepareScheduledTask(input: {\n  name?: string;\n  prompt: string;\n  recurrence?: string | null;\n  processAfter?: string;\n  script?: string | null;\n  dangerouslyOverrideRecurrenceLimit?: boolean;\n  timezone?: string;\n}): PreparedScheduledTask {\n  if (!input.prompt) throw new Error('--prompt is required');\n  const recurrence = input.recurrence ?? null;\n  const script = input.script ?? null;\n  const tz = input.timezone ?? TIMEZONE;\n  validateRecurrence(recurrence, tz);\n  enforceRecurrenceLimit(recurrence, input.dangerouslyOverrideRecurrenceLimit === true, script !== null, tz);\n\n  let processAfter: string;\n  if (input.processAfter === undefined && recurrence) {\n    const next = CronExpressionParser.parse(recurrence, { tz }).next().toISOString();\n    if (!next) throw new Error(`--recurrence has no upcoming run: ${recurrence}`);\n    processAfter = next;\n  } else {\n    processAfter = parseProcessAfter(input.processAfter, tz);\n  }\n\n  return { name: input.name, prompt: input.prompt, recurrence, script, processAfter };\n}\n","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/nanocoai/nanoclaw/blob/294ef2aee85218b23ad30eda9dfe10e590b54a8c/src/modules/scheduling/create.ts#L94-L130","documentation":"prepareScheduledTask requires a non-empty prompt — the textual instruction the scheduled agent will run is mandatory. Without it a task would have nothing to execute, so creation is rejected immediately with '--prompt is required'. This mirrors the CLI flag name of the same option.","triggerScenarios":"Calling prepareScheduledTask (directly or via a template task list / ncl tasks create) with prompt omitted, empty string, or undefined; building tasks programmatically from a config object where the prompt key is misspelled or conditionally unset.","commonSituations":"A template generates multiple tasks and one entry lacks a prompt field; a script constructs the task object dynamically and the prompt variable is undefined; users assuming recurrence alone is enough to define a task.","solutions":["Pass a non-empty prompt: prepareScheduledTask({ prompt: 'Summarize inbox', ... }).","If generating tasks from templates/config, validate each entry has a prompt before calling prepareScheduledTask.","Check for typos in the option key ('prompts', 'text', 'message' instead of 'prompt').","Default it deliberately, e.g. prompt: input.prompt ?? fallbackText, only if a sensible default exists."],"exampleFix":"// before\nawait prepareScheduledTask({ recurrence: '0 9 * * *' });\n\n// after\nawait prepareScheduledTask({ prompt: 'Summarize the inbox', recurrence: '0 9 * * *' });","handlingStrategy":"validation","validationCode":"if (!input?.prompt || !input.prompt.trim()) throw new Error('task prompt missing — refusing to call prepareScheduledTask');","typeGuard":"const hasPrompt = (t: { prompt?: string | null }): t is { prompt: string } => typeof t.prompt === 'string' && t.prompt.trim().length > 0;","tryCatchPattern":null,"preventionTips":["Make prompt a required TypeScript field in your own task type.","Validate generated task lists (e.g. from templates) before mapping to prepareScheduledTask."],"tags":["scheduling","required-field","tasks","input-validation"],"backgroundTag":"missing-required-parameter","analyzedSha":"294ef2aee85218b23ad30eda9dfe10e590b54a8c","analyzedAt":"2026-08-28T13:59:10.357Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}