Skip to content

fix(api): seed default Cancelled state in the "cancelled" group#350

Open
cavidelizade wants to merge 1 commit into
Devlaner:mainfrom
cavidelizade:fix/cancelled-state-group
Open

fix(api): seed default Cancelled state in the "cancelled" group#350
cavidelizade wants to merge 1 commit into
Devlaner:mainfrom
cavidelizade:fix/cancelled-state-group

Conversation

@cavidelizade

@cavidelizade cavidelizade commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Summary

The default "Cancelled" state was seeded with the group "canceled" (one L) while the rest of the backend matches on "cancelled" (two L). Since it's the default for every new project, several things quietly broke.

Linked issues

Closes #333

Type of change

  • Bug fix (fix:)

Surface

  • API (apps/api/)
  • Database migration (apps/api/migrations/)

What changed

  • state.go: seed the default Cancelled state with group "cancelled".
  • Migration 000013: UPDATE states SET "group" = 'cancelled' WHERE "group" = 'canceled' to fix existing projects. The down migration is a documented no-op (reversing a typo fix isn't safe, we can't tell which rows were originally mistyped).
  • Test TestDefaultProjectStatesUseValidGroups: asserts every default state's group is in validStateGroups, so this kind of typo fails the build next time.

What this fixes

With the wrong group, for every new project: auto-close silently did nothing (CloseInactiveBefore matches group = 'cancelled'), auto-archive skipped cancelled issues, progress charts counted cancelled work as backlog, and open/closed filters treated cancelled issues as open.

Test plan

  • go test ./... green (new test included)
  • go vet ./... clean
  • Migration filename follows the NNNNNN_name.{up,down}.sql convention and applies as a plain UPDATE

AI assistance

  • AI tools were used, tool(s): Claude Code (Opus 4.8), and AI-assisted commits carry a Co-Authored-By: trailer

Summary by CodeRabbit

  • Bug Fixes
    • Corrected the default “Cancelled” workflow state grouping to use the accepted cancelled value.
    • Updated existing records to ensure cancellation-related automation and progress reporting work consistently.
  • Tests
    • Added validation to ensure default workflow states use supported group values.

The default Cancelled state was seeded with the group "canceled" (one L) while
the rest of the app matches on "cancelled" (two L). For every new project that
made auto-close a silent no-op, kept cancelled issues out of auto-archive, and
mis-bucketed them as backlog in cycle/module/epic progress, and it made
cancelled issues read as open in open/closed filters.

Fix the seed and add migration 000013 to correct existing rows. A test now
asserts every default state uses a group in validStateGroups so this class of
typo can't come back.

Closes Devlaner#333

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@cavidelizade
cavidelizade requested a review from a team as a code owner July 16, 2026 20:01
@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f4d9ac95-980a-4bea-804c-bd40a3a5e5e9

📥 Commits

Reviewing files that changed from the base of the PR and between 61bc903 and 19c9915.

📒 Files selected for processing (4)
  • apps/api/internal/service/state.go
  • apps/api/internal/service/state_default_test.go
  • apps/api/migrations/000013_fix_cancelled_state_group.down.sql
  • apps/api/migrations/000013_fix_cancelled_state_group.up.sql

📝 Walkthrough

Walkthrough

The default Cancelled workflow state now uses the canonical "cancelled" group. A test validates default state groups, and a migration updates existing persisted rows with a deliberate no-op rollback.

Changes

Cancelled state group correction

Layer / File(s) Summary
Canonical default state and validation
apps/api/internal/service/state.go, apps/api/internal/service/state_default_test.go
The default Cancelled state uses "cancelled", and tests verify all default groups against validStateGroups plus the exact Cancelled mapping.
Persisted state data correction
apps/api/migrations/000013_fix_cancelled_state_group.up.sql, apps/api/migrations/000013_fix_cancelled_state_group.down.sql
Existing state rows are updated from "canceled" to "cancelled"; rollback performs no data reversal.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested labels: API, improvement

Poem

A bunny found one letter astray,
And fixed the state group today.
Two Ls now hop,
Tests guard the crop,
While old rows join the right way.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise, conventional, and accurately describes the main change to the Cancelled seed group.
Description check ✅ Passed The description is mostly complete and covers the required sections, with the migration details and tests clearly documented.
Linked Issues check ✅ Passed The PR fixes the seeded group spelling, adds a data migration, and adds a test, matching the linked issue's requirements.
Out of Scope Changes check ✅ Passed The changes stay focused on the Cancelled group typo fix, its migration, and validation test.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.12.2)

level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies"


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

Default Cancelled state seeded with wrong group ("canceled" vs "cancelled") breaks auto-close, archive and progress

1 participant