Description
What's going on?
Following up on closed issue #43274 to isolate individual reproducible cases. This report covers the error handling when invoking browser_cookie_set on a blank tab (about:blank) without an explicit domain.
When an agent or user invokes browser_cookie_set immediately after opening a browser or on an unnavigated tab (about:blank):
{
"name": "browser_cookie_set",
"arguments": {
"name": "session_id",
"value": "xyz123"
}
}In packages/playwright-core/src/tools/backend/cookies.ts (lines 103–109):
const url = new URL(tab.page.url());
const cookie: any = {
name: params.name,
value: params.value,
domain: params.domain || url.hostname,
path: params.path || '/',
};On about:blank, new URL('about:blank').hostname is "". When params.domain is omitted, cookie.domain becomes "".
When passed to browserContext.addCookies([cookie]), Playwright's internal validation in packages/playwright-core/src/server/network.ts line 165 checks:
assert(c.url || (c.domain && c.path), 'Cookie should have a url or a domain/path pair');Because c.domain === "", (c.domain && c.path) evaluates to "" (falsy), and Playwright throws an internal assertion failure:
Error: browserBackend.callTool: Cookie should have a url or a domain/path pair
Reproduction
test('browser_cookie_set on about:blank without domain', async ({ startClient }) => {
const { client } = await startClient({ config: { capabilities: ['storage'] } });
const response = await client.callTool({
name: 'browser_cookie_set',
arguments: { name: 'session_id', value: 'xyz123' },
});
// Fails with: Error: browserBackend.callTool: Cookie should have a url or a domain/path pair
});Expected Behavior
Rather than crashing with an internal core assertion error (Cookie should have a url or a domain/path pair), browser_cookie_set should validate that the domain can be determined and report an actionable error to the client/LLM:
Cannot infer cookie domain from current page URL "about:blank". Please specify "domain".
Version
Playwright main / 1.65.0-next

Activity
alok-108 commentedon Oct 12, 2026
I have tested and verified this case independently in isolation on blank sessions. I will be opening a PR shortly to handle this with a clear validation error.
chore: mark v0.1.23 (#494)