Skip to content

Tasks with invalid type silently dropped on read (no write-time validation) #899

@DonutsDelivery

Description

@DonutsDelivery

Bug

Tasks created with an invalid type value (e.g. feature) are accepted and written to project.tasks.yaml, but silently dropped when read back. This causes tasks to "disappear" with no error or warning.

Steps to Reproduce

  1. Create a task with type: feature (via daemon API or CLI)
  2. Verify the task exists in project.tasks.yaml (it does)
  3. Run kspec task list — the task is missing from output
  4. The daemon API GET /api/tasks also omits it

Root Cause

loadTasksFromFile() in dist/parser/yaml.js uses TaskSchema.safeParse() for individual task validation. When safeParse fails, the task is silently skipped:

for (const taskData of taskList) {
    const result = TaskSchema.safeParse(taskData);
    if (result.success) {
        tasks.push({ ...result.data, _sourceFile: filePath });
    }
    // ← no else branch — invalid tasks silently dropped
}

TaskTypeSchema only allows: epic | task | bug | spike | infra. The value feature fails Zod validation:

Invalid enum value. Expected 'epic' | 'task' | 'bug' | 'spike' | 'infra', received 'feature'

Two Issues

1. No write-time validation

The daemon API POST /api/tasks and createTask() do not validate against TaskSchema before writing. Invalid data is accepted and persisted.

2. Silent data loss on read

When safeParse fails, the task is dropped with no warning, no log, no error. The user sees N-1 tasks and has no idea one is missing or why.

Expected Behavior

  • Write time: Reject invalid types with a clear error (400 response or CLI error)
  • Read time: At minimum, warn about tasks that fail validation. Ideally, still include them with a warning flag rather than silently dropping them.

Environment

  • kspec v0.12.0 (@kynetic-ai/spec)
  • Also reproduced on v0.10.0 and v0.11.0
  • Bun v1.3.10, Linux x64

Workaround

Manually edit the YAML to change the invalid type to a valid one (e.g. featuretask).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions