Describe the bug
StateManagerDisk.load_state() catches every deserialization exception and returns None without logging or distinguishing corruption from a missing state file. get_state() then treats the corrupted file as a brand-new state and can later overwrite the persisted data with defaults, causing silent backend state loss.
To Reproduce
import asyncio
import tempfile
from pathlib import Path
from reflex.istate.manager.disk import StateManagerDisk
from reflex.istate.manager.token import StateToken
async def main():
with tempfile.TemporaryDirectory() as tmp:
manager = StateManagerDisk()
manager.__dict__["states_directory"] = Path(tmp)
token = StateToken(ident="client", cls=int)
manager.token_path(token).write_bytes(b"not-a-pickle")
print("load_state:", await manager.load_state(token))
print("get_state:", await manager.get_state(token))
await manager.close()
asyncio.run(main())
Describe the bug
StateManagerDisk.load_state()catches every deserialization exception and returnsNonewithout logging or distinguishing corruption from a missing state file.get_state()then treats the corrupted file as a brand-new state and can later overwrite the persisted data with defaults, causing silent backend state loss.To Reproduce