fix(print): prevent white page when persisted state JSON is invalid#871
Open
akira69 wants to merge 4 commits intoDonkie:masterfrom
Open
fix(print): prevent white page when persisted state JSON is invalid#871akira69 wants to merge 4 commits intoDonkie:masterfrom
akira69 wants to merge 4 commits intoDonkie:masterfrom
Conversation
11 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_urlhandling.What Changed
useSavedState(...)now validates parsed values against the expected shape, removes malformedsavedStates-*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.tsxnow accepts legacy raw-stringbase_urlvalues, ignores unusable non-string values, and falls back towindow.location.originwhen no usable value exists.Testing Performed
cd client && ./node_modules/.bin/eslint src/utils/saveload.ts src/pages/printing/spoolQrCodePrintingDialog.tsxcd client && ./node_modules/.bin/prettier --check src/utils/saveload.ts src/pages/printing/spoolQrCodePrintingDialog.tsxcd client && VITE_APIURL=/api/v1 npm run buildPATH=.venv/bin:$PATH SPOOLMAN_DIR_DATA=/tmp/spoolman_pr_871_data uv run uvicorn spoolman.main:app --host 0.0.0.0 --port 9871http://localhost:9871covering:savedStates-*on/spool/print?spools=1&return=%2Fspool%2FprintsavedStates-spoolList-showArchivedplus malformedspoolList-v2-*localStorage on/spool#sorters,#filters, and legacy#paginationhash state on/spoolbase_urlbase_urlfallback towindow.location.originTest Checklist
/spool/print?spools=1&return=%2Fspool%2Fprintrenders with malformedsavedStates-*/spoolrenders with malformed saved table localStoragebase_urlis accepted on spool printbase_urlfalls back towindow.location.origin