Skip to content

fix(printers): validate updates and keep default selection consistent #227

Closed

Description

@khaira777

Summary

The printer API has several confirmed consistency and validation problems:

  • Concurrent requests can leave zero or multiple default printers.
  • Updates accept invalid connection types and port values.
  • KOT printing does not apply the same JSON field parsing as bill printing.
  • Deleting the default printer leaves printing unavailable until manual repair.
  • Updates conflate omitted fields with explicit empty or zero values.

Why this matters

Printing can stop unexpectedly, invalid configuration can be persisted, and KOT output can be incomplete or malformed.

Relevant code

  • main/routes/printers.ts
  • main/routes/kitchen-stations.ts
  • main/thermal.ts

Acceptance criteria

  • Default-printer changes are atomic and maintain the intended invariant.
  • PUT validates connection type and port range consistently with POST.
  • KOT and bill printing use the same effective item/add-on parsing contract.
  • Deleting a default printer has an explicit safe behavior: prevent deletion or select a valid replacement.
  • API updates distinguish omitted fields from explicit null/empty/zero values.
  • Add concurrent and malformed-input regression tests.

Additional confirmed case

The kitchen-station update endpoint accepts an empty printer identifier and allows the database foreign-key error to become HTTP 500 instead of returning a client-validation response.

Relevant code: main/routes/kitchen-stations.ts:53-56,89-116.

Acceptance criteria:

  • Treat empty or malformed printer identifiers as a clear 400 validation response.
  • Keep valid printer assignment and explicit clearing behavior working.
  • Add malformed-input coverage for create and update paths.

Activity

  1. added
    area:backend
    on Aug 9, 2026
  2. self-assigned this
    on Aug 16, 2026
  3. added a commit that references this issue on Aug 16, 2026
    85fae10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:backend

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions