Skip to content

fix(catalog): enforce category tree and nullable-field update invariants #247

Description

@khaira777

Summary

Category writes accept empty/whitespace names, missing parents, self-parenting, and cycles. Deletion does not define child handling and can reassign products to the category being deleted. COALESCE-based updates also prevent explicit clearing of nullable catalog fields.

Current behavior

  • main/routes/categories.ts:59-107,135-148 accepts invalid parent relationships and empty names.
  • Category deletion does not reject reassign_to equal to the category being deleted.
  • COALESCE update expressions in category/product/add-on routes treat explicit null as “preserve existing value”.

Expected behavior

The category hierarchy should remain valid, deletion/reassignment behavior should be explicit and transactional, and omitted fields should be distinguishable from explicit null-clears.

Acceptance criteria

  • Trim and require non-empty category names.
  • Require existing active parents and reject self/ancestor cycles.
  • Reject reassignment to the category being deleted.
  • Define and test child-category handling on parent deletion.
  • Use presence-aware update semantics so explicit null can clear nullable catalog fields.

Relevant files

main/routes/categories.ts, main/routes/products.ts, main/routes/addon-groups.ts

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:backendBackend (Express/SQLite)bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions