Skip to content

Commit dcbca6c

Browse files
os-zhuangclaude
andauthored
chore(todo): fix owner lookup ref + completed-task seed validation (#2008)
Two app-todo defects found driving it end-to-end: 1. todo_task.owner was Field.lookup('user') — `user` is not a registered object/table (the platform user object is `sys_user`), so seed-time owner resolution flooded "no such table: user". Repointed to `sys_user` and dropped the unresolvable `owner: 'admin'` seed value (no stable seed key for the auth-created bootstrap admin). 2. The two `completed` seed tasks omitted `completed_date`, violating the object's own `completed_date_required` validation → they silently failed to seed (only 6 of 8 rows loaded). Gave them a completed_date. Verified: 0 "no such table: user" errors, 0 rule_violations, all 8 rows seed; validation still rejects a completed task with no completed_date (400); aggregation/reports unaffected. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 9afeb2d commit dcbca6c

3 files changed

Lines changed: 21 additions & 10 deletions

File tree

‎.changeset/todo-seed-fixes.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
---
3+
4+
chore(todo): fix two app-todo defects found driving it end-to-end — (1) `todo_task.owner` was a lookup to `user`, which isn't a registered object, so seed/owner resolution hit "no such table: user" (the platform user object is `sys_user`); (2) the two `completed` seed tasks omitted `completed_date`, violating the object's own `completed_date_required` validation, so they silently failed to seed (6 of 8 rows loaded). Repointed the lookup to `sys_user`, dropped the unresolvable `owner: 'admin'` seed value, and gave completed seeds a `completed_date`. Now all 8 rows seed; validation still rejects a completed task with no date. Example-app only.

‎examples/app-todo/src/data/index.ts‎

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,20 @@ import { Task } from '../objects/task.object';
77
const tasks = defineSeed(Task, {
88
mode: 'upsert',
99
externalId: 'subject',
10+
// NOTE: `owner` is a lookup to `sys_user`; there's no stable seed key for the
11+
// bootstrap admin (created by auth), so it's left unset rather than pointing
12+
// at a non-existent 'admin'. Completed tasks MUST carry `completed_date` — the
13+
// object's `completed_date_required` validation rejects the row otherwise
14+
// (this is why the two completed seeds previously failed to load).
1015
records: [
11-
{ subject: 'Learn ObjectStack', status: 'completed', priority: 'high', category: 'work', owner: 'admin' },
12-
{ subject: 'Build a cool app', status: 'in_progress', priority: 'normal', category: 'work', owner: 'admin', due_date: cel`daysFromNow(3)` },
13-
{ subject: 'Review PR #102', status: 'completed', priority: 'high', category: 'work', owner: 'admin' },
14-
{ subject: 'Write Documentation', status: 'not_started', priority: 'normal', category: 'work', owner: 'admin', due_date: cel`daysFromNow(1)` },
15-
{ subject: 'Fix Server bug', status: 'waiting', priority: 'urgent', category: 'work', owner: 'admin' },
16-
{ subject: 'Buy groceries', status: 'not_started', priority: 'low', category: 'shopping', owner: 'admin', due_date: cel`today()` },
17-
{ subject: 'Schedule dentist appointment',status: 'not_started', priority: 'normal', category: 'health', owner: 'admin', due_date: cel`daysFromNow(7)` },
18-
{ subject: 'Pay utility bills', status: 'not_started', priority: 'high', category: 'finance', owner: 'admin', due_date: cel`daysFromNow(2)` },
16+
{ subject: 'Learn ObjectStack', status: 'completed', priority: 'high', category: 'work', completed_date: cel`daysAgo(2)` },
17+
{ subject: 'Build a cool app', status: 'in_progress', priority: 'normal', category: 'work', due_date: cel`daysFromNow(3)` },
18+
{ subject: 'Review PR #102', status: 'completed', priority: 'high', category: 'work', completed_date: cel`daysAgo(1)` },
19+
{ subject: 'Write Documentation', status: 'not_started', priority: 'normal', category: 'work', due_date: cel`daysFromNow(1)` },
20+
{ subject: 'Fix Server bug', status: 'waiting', priority: 'urgent', category: 'work' },
21+
{ subject: 'Buy groceries', status: 'not_started', priority: 'low', category: 'shopping', due_date: cel`today()` },
22+
{ subject: 'Schedule dentist appointment',status: 'not_started', priority: 'normal', category: 'health', due_date: cel`daysFromNow(7)` },
23+
{ subject: 'Pay utility bills', status: 'not_started', priority: 'high', category: 'finance', due_date: cel`daysFromNow(2)` },
1924
],
2025
});
2126

‎examples/app-todo/src/objects/task.object.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,10 @@ export const Task = ObjectSchema.create({
7373
readonly: true,
7474
}),
7575

76-
// Assignment
77-
owner: Field.lookup('user', {
76+
// Assignment — the platform user object is `sys_user` (better-auth managed);
77+
// `user` is not a registered object/table, so the old reference resolved to
78+
// a non-existent `user` table at seed/lookup time ("no such table: user").
79+
owner: Field.lookup('sys_user', {
7880
label: 'Assigned To',
7981
}),
8082

0 commit comments

Comments
 (0)