-
-
Notifications
You must be signed in to change notification settings - Fork 52.7k
Description
Summary
openclaw browser cookies set <name> <value> --url <target-url> always fails with:
error: required option '--url <url>' not specified
Even though --url is clearly passed. The cookie value is never set.
Root Cause
In src/cli/browser-cli.ts (line ~44), addGatewayClientOptions(browser) adds a --url <url> option to the parent browser command (for the gateway WebSocket URL). Commander.js captures --url at the parent level before the set subcommand can see it.
In src/cli/browser-cli-state.cookies-storage.ts (line ~61), the set subcommand adds .requiredOption("--url <url>", ...) for the target cookie URL. But the parent already consumed it.
The existing test at browser-cli-state.option-collisions.test.ts (line ~67) passes because it does not include addGatewayClientOptions in its mock setup — so the collision is never exercised.
Impact
/cookies/setHTTP endpoint works correctly — Playwright'scontext.addCookies()properly injects cookies into the networking context- The CLI is the only broken path — the
--urlcollision prevents the endpoint from being reached - Agents that need authenticated browser testing (HttpOnly session cookies) have no working CLI path
- Workaround: Use the gateway WebSocket RPC directly to call
/cookies/set, or navigate through the login UI manually
Suggested Fix
Use the existing inheritOptionFromParent() pattern from command-options.ts (already used for --target-id collision):
- Change
setsubcommand from.requiredOption("--url")to.option("--url") - Add a
resolveCookieUrl()helper that checks local opts first, then walks ancestors viainheritOptionFromParent() - Also check
--browser-profilepropagation to nested subcommands (same root cause) - Update the test to include
addGatewayClientOptionsin the mock so the real collision is covered
Reproduction
# This should set a cookie but fails:
openclaw browser cookies set "connect.sid" "s%3Axyz" --url "https://example.com"
# error: required option '--url <url>' not specified
# The HTTP endpoint works fine:
curl -X POST http://127.0.0.1:18789/browser/cookies/set \
-H "Content-Type: application/json" \
-d '{"cookie": {"name": "connect.sid", "value": "s%3Axyz", "url": "https://example.com"}}'Environment
- OpenClaw 2026.2.23 (commit a6a2a92)
- macOS 15.3 (arm64)
- Node v25.5.0