Repository navigation
feat(core): add label CRUD service - #22
Conversation
|
my claude found a mistake. Issue: {"parentID": ""} (an empty string) returns a 500 instead of a 404. The service treats "" as "no parent", skips checking that the parent exists, and then inserts parent_id = "", which fails the database's foreign key check. u just got claudemogged |
Yumeseeker
left a comment
There was a problem hiding this comment.
For create and update, if the parentID is "", it could bypass the requireRow check. maybe make code explicit like if (parentID !== null)...
Shouldn't matter for users since all created labels are validated, but could be an edge case for internal use?
|
@jahuang24 @Yumeseeker thanks for catching this! Fixed in ccc8550: create and update now check |
Issue for this PR
Closes #14
Type of change
What does this PR do?
Adds a
Labelservice (packages/core/src/label.ts) with create, get, list, update, and remove for labels. Built on top of #21 (label table), so the base isbrianz2/database-labelsuntil that merges.Invalid operations fail with typed errors instead of doing something weird:
NotFoundErrorInvalidNameErrorDuplicateNameErrorCycleErrorDeleting a label also deletes its child labels and returns all deleted IDs, so #15 can clean up session assignments. Open to feedback on this and on requiring unique sibling names.
How did you verify your code works?
Added
packages/core/test/label.test.tswith 18 tests covering each operation and every invalid case above. Run withbun test test/label.test.tsinpackages/core; all pass. Typecheck and Prettier also pass.Screenshots / recordings
N/A, backend only
Checklist