Repository navigation
fix(StateManagerDisk): log error when corrupted state file is encountered - #7323
dajiaohuang wants to merge 10 commits into
Conversation
…ered Previously, a corrupted pickle file on disk would silently return None, treating it the same as a missing file. Now an error is logged with the token and path information before returning None, making corruption observable without breaking the recovery behavior of returning default state.
[Medium impact] The PR appears safe to merge, with a non-blocking gap in warnings for corrupted Findings
SummaryAdds a warning for unexpected disk-state load failures while keeping the existing fresh-state fallback.
Reviews (7) · Last reviewed commit: "Merge remote-tracking branch 'upstream-g..." · Reviewed by Greptile |
There was a problem hiding this comment.
All reported issues were addressed across 3 files
Tip: cubic used a learning from your PR history. Let your coding agent read cubic learnings directly with the cubic MCP.
Re-trigger cubic
|
The follow-up at Final focused disk tests: 9 passed. Repository Ruff and format checks, targeted Pyright, and Current post-push snapshot at |
Merging this PR will not alter performance
|
There was a problem hiding this comment.
All reported issues were addressed across 2 files (changes from recent commits).
You’re at about 90% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact contact@cubic.dev.
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
FarhanAliRaza
left a comment
There was a problem hiding this comment.
I tested this PR in a small app with state_manager_mode="disk". The app has a counter state and a notes state. I drove it in a browser and triggered backend hot reloads by editing the app file.
On main, a corrupt state file resets the state and logs nothing. On this PR, the same corrupt file logs one error per state file, and the page loads with default state. A plain restart keeps the state and logs nothing. A missing file logs nothing. The unit tests in test_disk.py pass.
I also added a field to a state class and reloaded. That path now logs an ERROR for a normal schema change.
Requested changes are in the inline comments.
|
The requested changes are in The focused disk tests pass (9/9). Current-head hosted checks now report 145 successful and 3 skipped checks, with no failed or pending checks. This includes the unit, integration, application-harness, package-build and performance gates. Ready for another review; the hosted checks do not substitute for your browser hot-reload reproduction. |
# Conflicts: # tests/units/istate/manager/test_disk.py
| except StateSchemaMismatchError: | ||
| return None |
There was a problem hiding this comment.
Corrupted sessions stay silent
Corrupted BaseState files still produce no warning. BaseStateToken.deserialize calls BaseState._deserialize, which wraps every unpickling failure—including invalid or truncated data—in StateSchemaMismatchError. This handler silently returns None, so normal Reflex sessions fall back to fresh state without explaining why their saved values disappeared.
Distinguish actual schema changes from failed unpickling, and test corruption through BaseStateToken.
Summary
Disk state loading now warns with the hashed filename and exception type/message when unexpected deserialization fails, then retains the existing default-state fallback. Expected StateSchemaMismatchError during hot reload returns None silently, matching Redis recovery.
The review revisions remove unrelated client-ID refactors, share warning-record filtering, use repr formatting for the exception message, and remove whitespace collapsing, message truncation and the added punctuation. Token redaction remains intentionally scoped: deserializers may include the session identifier in an exception message, as the regression test demonstrates. Formatting alone is not a redaction boundary.
Validation
Scope
The state fallback behavior is unchanged. News fragment updated; no public component API or dependency changes.