Skip to content

fix(print): prevent white page when persisted state JSON is invalid#871

Open
akira69 wants to merge 4 commits intoDonkie:masterfrom
akira69:fix/print-white-page-parse-guards
Open

fix(print): prevent white page when persisted state JSON is invalid#871
akira69 wants to merge 4 commits intoDonkie:masterfrom
akira69:fix/print-white-page-parse-guards

Conversation

@akira69
Copy link
Copy Markdown

@akira69 akira69 commented Feb 25, 2026

Summary

Prevents blank-page failures when persisted frontend state is malformed. This stays a frontend-only robustness fix scoped to saved-state recovery and spool print base_url handling.

What Changed

  • useSavedState(...) now validates parsed values against the expected shape, removes malformed savedStates-* entries, and avoids writing "undefined" back to localStorage when state is unset.
  • useInitialTableState(...) now validates saved sorters, filters, pagination, and show-columns state, removes malformed localStorage/hash entries, and normalizes legacy pagination from { current } to { currentPage }.
  • client/src/pages/printing/spoolQrCodePrintingDialog.tsx now accepts legacy raw-string base_url values, ignores unusable non-string values, and falls back to window.location.origin when no usable value exists.

Testing Performed

  • cd client && ./node_modules/.bin/eslint src/utils/saveload.ts src/pages/printing/spoolQrCodePrintingDialog.tsx
  • cd client && ./node_modules/.bin/prettier --check src/utils/saveload.ts src/pages/printing/spoolQrCodePrintingDialog.tsx
  • cd client && VITE_APIURL=/api/v1 npm run build
  • PATH=.venv/bin:$PATH SPOOLMAN_DIR_DATA=/tmp/spoolman_pr_871_data uv run uvicorn spoolman.main:app --host 0.0.0.0 --port 9871
  • Real Playwright validation on http://localhost:9871 covering:
    • malformed savedStates-* on /spool/print?spools=1&return=%2Fspool%2Fprint
    • malformed savedStates-spoolList-showArchived plus malformed spoolList-v2-* localStorage on /spool
    • malformed #sorters, #filters, and legacy #pagination hash state on /spool
    • raw-string base_url
    • empty/default base_url fallback to window.location.origin

Test Checklist

  • /spool/print?spools=1&return=%2Fspool%2Fprint renders with malformed savedStates-*
  • /spool renders with malformed saved table localStorage
  • malformed hash state is cleaned up and legacy pagination is normalized
  • raw-string base_url is accepted on spool print
  • empty/default base_url falls back to window.location.origin

@akira69 akira69 marked this pull request as ready for review February 25, 2026 23:14
@akira69 akira69 marked this pull request as draft February 26, 2026 16:47
@akira69 akira69 marked this pull request as ready for review February 27, 2026 02:19
@akira69 akira69 closed this Mar 2, 2026
@akira69 akira69 reopened this Mar 2, 2026
@akira69 akira69 marked this pull request as draft March 14, 2026 06:20
@akira69 akira69 marked this pull request as ready for review March 19, 2026 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant