feat: show and forget the barcodes of a stock item #6

Merged
tomas merged 3 commits from fix/stock-codes-and-api-errors into master 2026-11-11 17:56:16 +00:00
Owner

Summary

Three fixes from the list of improvements, one commit each.

  • feat: show and forget the barcodes of a stock item. A code assigned to the wrong item could only be undone by deleting the item. The stock item's editor now lists its codes with package sizes and can forget one; the next scan of that code asks again what it is.
  • fix: answer unauthenticated API requests with 401 instead of 500. For a request without Accept: application/json (browser, curl, monitoring), the auth middleware built a redirect to the login route, which the API doesn't have, and failed with a 500. Guests are no longer redirected, so the usual JSON 401 is rendered.
  • fix: ignore trailing slashes in FRONTEND_URL. With a trailing slash, password and invitation links became https://app//set-password (the SPA's 404) and the CORS origin matched no browser. Each origin is now trimmed.

No API or database change.

Testing

  • make ci passed: backend, frontend (lint, svelte-check, Vitest, Playwright, build) and commits.
  • New Pest tests, both failing before the fix: the 401 for text/html, */* and no Accept; FRONTEND_URL with trailing slashes and spaces for links and CORS.
  • New Playwright test: the item editor shows a code and forgets it.
  • Checked screenshots of the editor at 390 px and 820 px.
## Summary Three fixes from the list of improvements, one commit each. - **feat: show and forget the barcodes of a stock item.** A code assigned to the wrong item could only be undone by deleting the item. The stock item's editor now lists its codes with package sizes and can forget one; the next scan of that code asks again what it is. - **fix: answer unauthenticated API requests with 401 instead of 500.** For a request without `Accept: application/json` (browser, curl, monitoring), the auth middleware built a redirect to the `login` route, which the API doesn't have, and failed with a 500. Guests are no longer redirected, so the usual JSON 401 is rendered. - **fix: ignore trailing slashes in FRONTEND_URL.** With a trailing slash, password and invitation links became `https://app//set-password` (the SPA's 404) and the CORS origin matched no browser. Each origin is now trimmed. No API or database change. ## Testing - `make ci` passed: backend, frontend (lint, svelte-check, Vitest, Playwright, build) and commits. - New Pest tests, both failing before the fix: the 401 for `text/html`, `*/*` and no `Accept`; `FRONTEND_URL` with trailing slashes and spaces for links and CORS. - New Playwright test: the item editor shows a code and forgets it. - Checked screenshots of the editor at 390 px and 820 px.
The auth middleware builds a redirect to the `login` route for a request
that doesn't ask for JSON. The API has no such route, so a browser, curl
or monitoring request without `Accept: application/json` got a 500 and
an error in the log. Guests are no longer redirected anywhere, so the
AuthenticationException is rendered as the usual JSON 401.
FRONTEND_URL was used as written. With a trailing slash, the password
and invitation links became https://app//set-password, which the SPA
answers with "page not found", and the CORS origin ended in a slash that
no browser's Origin header matches, so every API call failed. Each
origin is now trimmed of spaces and trailing slashes.
feat: show and forget the barcodes of a stock item
All checks were successful
CI / backend (pull_request) Successful in 1m32s
CI / commits (pull_request) Successful in 43s
CI / frontend (pull_request) Successful in 3m19s
CI / release (pull_request) Has been skipped
CI / commits (push) Successful in 39s
CI / backend (push) Successful in 1m30s
CI / frontend (push) Successful in 3m8s
CI / release (push) Successful in 47s
CI / images (pull_request) Has been skipped
CI / images (push) Successful in 1m11s
e3ef7f13c9
A code assigned to the wrong item could only be undone by deleting the
item. The stock item's editor now lists the codes the household has
taught the app for it, with their package sizes, and can forget one; the
next scan of a forgotten code asks again what it is. The scanner
refreshes the codes after assigning one.
tomas merged commit e3ef7f13c9 into master 2026-11-11 17:56:16 +00:00
tomas deleted branch fix/stock-codes-and-api-errors 2026-11-11 17:56:16 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
tomas/household!6
No description provided.