Fix - vibium storage restore fails to restore localStorage/sessionStorage - #218
Closed
Jhoan0714 wants to merge 4 commits into
Closed
Fix - vibium storage restore fails to restore localStorage/sessionStorage#218Jhoan0714 wants to merge 4 commits into
Jhoan0714 wants to merge 4 commits into
Conversation
Contributor
hugs
added a commit
that referenced
this pull request
Aug 3, 2026
vibium storage / storage restore had no test coverage at all, which is how the double-encoding bug in #217 shipped and stayed unnoticed. Covers the export shape, the restore round trip, and the unwrap that keeps state files written in the old shape loading. All three fail against the pre-#217 code. Adapted from a test contributed by @Jhoan0714 in #218.
hugs
added a commit
that referenced
this pull request
Aug 3, 2026
vibium storage / storage restore had no test coverage at all, which is how the double-encoding bug in #217 shipped and stayed unnoticed. Covers the export shape, the restore round trip, and the unwrap that keeps state files written in the old shape loading. All three fail against the pre-#217 code. Adapted from a test contributed by @Jhoan0714 in #218.
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
This PR fixes #217 —
browserStorageStatedouble-encoded the exported storage state, sovibium storage restoresilently failed to restorelocalStorage/sessionStorageeven though it reported success.Root Cause
browserStorageStateinclicker/internal/agent/handlers.goran a script that already callsJSON.stringify(...)in the browser, and then embedded that resulting string directly into the exportedstatemap before a secondjson.MarshalIndentpass — so the"storage"field ended up as an escaped JSON string instead of a nested JSON object.browserRestoreStorageinterpolates that field directly intovar state = %s;when restoring, so the escaped string became a JS string literal instead of an object, andstate.localStorage/state.sessionStoragewereundefined— nothing was restored, with no error reported.Why this matters
vibium storage/vibium storage restoreare the only CLI/MCP commands for saving and reusing browser session state (e.g. login sessions) across runs — this bug made that workflow completely non-functionalcontext.storage()/context.setStorage()use a separate, unaffected wire-API code path (vibium:context.storage/setStorage→handleContextStorageinclicker/internal/api/handlers_storage.go)Validation
Executed:
Before fix —
state.jsonhad"storage"as an escaped string, and restore silently failed:{ "cookies": [], "storage": "{\"origin\":\"https://sahitest.com\",\"localStorage\":{\"user\":\"alice\"},\"sessionStorage\":{\"session_id\":\"abc123\"}}" }After fix —
state.jsonhas"storage"as a real nested object, and restore works:{ "cookies": [], "storage": { "localStorage": { "user": "alice" }, "origin": "https://sahitest.com", "sessionStorage": { "session_id": "abc123" } } }Test added:
