Skip to content

feat: validate project exists before creating tasks#121

Merged
bborn merged 1 commit intomainfrom
task/230-do-not-allow-creating-tasks-in-nonexisti
Jan 11, 2026
Merged

feat: validate project exists before creating tasks#121
bborn merged 1 commit intomainfrom
task/230-do-not-allow-creating-tasks-in-nonexisti

Conversation

@bborn
Copy link
Copy Markdown
Owner

@bborn bborn commented Jan 11, 2026

Summary

  • Add validation in CreateTask to ensure the specified project exists before allowing task creation
  • Prevents creating tasks with non-existent project references
  • Returns clear project not found error when validation fails
  • Supports project aliases in validation (existing functionality preserved)
  • Defaults to 'personal' project when no project specified (which is auto-created)

Test plan

  • Run go test ./... - all tests pass
  • New tests added for project validation:
    • TestCreateTaskRejectsNonExistentProject - verifies error on non-existent project
    • TestCreateTaskAllowsExistingProject - verifies success with valid project
    • TestCreateTaskAllowsProjectAlias - verifies aliases work
    • TestCreateTaskDefaultsToPersonal - verifies default project behavior
  • Updated existing tests to create required projects before tasks

🤖 Generated with Claude Code

Add validation in CreateTask to ensure the specified project exists
in the database before allowing task creation. This prevents orphaned
tasks with non-existent project references.

Changes:
- Add ErrProjectNotFound error variable for consistent error handling
- Validate project existence in CreateTask using GetProjectByName
- Support project aliases in validation (existing functionality)
- Default to 'personal' project (which is auto-created) when no project specified

Tests:
- Add TestCreateTaskRejectsNonExistentProject
- Add TestCreateTaskAllowsExistingProject
- Add TestCreateTaskAllowsProjectAlias
- Add TestCreateTaskDefaultsToPersonal
- Update existing tests to create required projects before tasks

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@bborn bborn merged commit 9e2a5f3 into main Jan 11, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant