You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug] [Python] StorageState TypedDict doesn't have credentials and opfs entries #42732
playwrightcapture/capture.py: note: In member "initialize_context" of class "Capture":
playwrightcapture/capture.py:706: error: Argument "storage_state" to "new_context" of "Browser" has
incompatible type "dict[str, Any] | None"; expected "StorageState | str | Path | None" [arg-type]
storage_state=self.storage if self.storage else None,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
playwrightcapture/capture.py: note: In member "_finalize_capture" of class "Capture":
playwrightcapture/capture.py:1250: error: Value of "storage" has incompatible type "StorageState";
expected "dict[str, Any] | None" [typeddict-item]
to_return['storage'] = await self.context.storage_state(indexed_db=True,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Found 2 errors in 1 file (checked 8 source files)
Hi, I'm the Playwright bot and I took a first look at this.
Confirmed, and it's wider than the Python StorageState TypedDict — the declared storage state shape is stale in every language, because it's generated from the docs in this repo and those were never updated when the new options landed. BrowserContext.storageState() returns more than the type admits:
indexedDB per origin (option added in 1.51)
opfs per origin (1.63)
top-level credentials (1.61)
The server fills all three in (browserContext.ts#L617-L632 — result.credentials = ... and script.collect({ indexedDB, opfs })), but the documented return type is still just cookies + origins.localStorage. Same on the input side, so a storageState(...) → newContext({ storageState }) round trip doesn't type-check against what it actually produces.
So the Python fix needs the docs change here first, otherwise it drifts right back.
Where the type is declared
Source of truth (docs), both missing the new fields:
microsoft/playwright-python @ 40f7550 (the sha you linked) — _api_structures.py
no runtime repro run: this is a static typing gap, the values are present at runtime and the declaration is what's short
One thing worth splitting out: indexedDB, opfs and credentials are opt-in, so they're optional keys on the emitted state — whether the type marks them optional or always-present changes how mypy treats the round trip, and that's a call for a maintainer.
Triaged on Linux by the Playwright bot - agent run
Activity
shubhambhar007 commentedon Sep 15, 2026
Raphaël Vinot (@Rafiot) could you please assign this to me ,thanks! - raised PR microsoft/playwright-python#3201
github-actions commentedon Sep 15, 2026
Hi, I'm the Playwright bot and I took a first look at this.
Confirmed, and it's wider than the Python
StorageStateTypedDict — the declared storage state shape is stale in every language, because it's generated from the docs in this repo and those were never updated when the new options landed.BrowserContext.storageState()returns more than the type admits:indexedDBper origin (option added in 1.51)opfsper origin (1.63)credentials(1.61)The server fills all three in (
browserContext.ts#L617-L632—result.credentials = ...andscript.collect({ indexedDB, opfs })), but the documented return type is still justcookies+origins.localStorage. Same on the input side, so astorageState(...)→newContext({ storageState })round trip doesn't type-check against what it actually produces.So the Python fix needs the docs change here first, otherwise it drifts right back.
Where the type is declared
Source of truth (docs), both missing the new fields:
docs/src/api/class-browsercontext.md#L1553-L1570js-python-context-option-storage-stateindocs/src/api/params.md#L291-L307Which generates the equally stale
types.d.ts:The client-side type does the omission explicitly, which is where the asymmetry shows up:
And the Python mirror you linked,
StorageState/OriginStateinplaywright/_impl/_api_structures.py, has the same two fields and nothing else.What I checked
microsoft/playwright@9ae5377— docs, generatedtypes.d.ts, client types, serverstorageState()implementationmicrosoft/playwright-python@40f7550(the sha you linked) —_api_structures.pyOne thing worth splitting out:
indexedDB,opfsandcredentialsare opt-in, so they're optional keys on the emitted state — whether the type marks them optional or always-present changes how mypy treats the round trip, and that's a call for a maintainer.Triaged on Linux by the Playwright bot - agent run
dcrousso commentedon Sep 19, 2026
the incomplete storage state type is intentional microsoft/playwright-python#3094 (comment)
for an unchanged round trip, use
StorageStatefor both your stored value and result field rather thandict[str, Any]if you need to access the additional fields, define a local type and cast as suggested in microsoft/playwright-python#2796 (comment)