#23189: feat(browser): add custom userDataDir support for Chrome profiles
size: S
Cluster:
Browser Enhancements and Fixes
## Summary
- Allow browser profiles to specify a custom `userDataDir` path, overriding the default `~/.openclaw/browser/{profile}/user-data` location
- Merge `cdpPort`/`color` defaults into existing default profile when only `userDataDir` is set in config
- Validate `userDataDir` is an absolute path at schema parse time (cross-platform: Windows and Unix)
- Add runtime `path.isAbsolute` guard in `launchOpenClawChrome` as defense-in-depth
- Restore `cdpPort||cdpUrl` refine validation that was missing
- Make profile `color` optional in schema (fallback to resolved global color)
## Test plan
- [ ] Set `userDataDir` to a custom absolute path in browser profile config and verify Chrome launches using that directory
- [ ] Verify that omitting `userDataDir` still uses the default `~/.openclaw/browser/{profile}/user-data` path
- [ ] Verify schema rejects relative paths for `userDataDir`
- [ ] Verify schema still requires `cdpPort` or `cdpUrl` on profiles
- [ ] Verify profile with only `userDataDir` set on the default profile auto-fills `cdpPort` and `color`
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Added `userDataDir` field to browser profile configuration, allowing custom Chrome user data directory paths. The implementation includes schema validation for absolute paths (cross-platform), runtime validation in `launchOpenClawChrome`, and default merging for partial profiles. Made profile `color` optional in schema with fallback to global/resolved color. The changes integrate with existing browser profile system without breaking current functionality.
<h3>Confidence Score: 4/5</h3>
- Safe to merge with minor documentation concerns
- Implementation is sound with proper validation at both schema and runtime levels. Path validation correctly handles cross-platform absolute paths and rejects relative/tilde paths. The PR description contains an inaccuracy about restoring cdpPort/cdpUrl validation (it was never missing) and a misleading test plan item (cannot set only userDataDir without cdpPort/cdpUrl due to schema validation). No tests were added for the new feature. Code changes follow existing patterns and don't introduce security issues.
- No files require special attention - changes are straightforward and properly validated
<sub>Last reviewed commit: 0500ef9</sub>
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#16110: feat(browser): add browser.profiles.openclaw.userDataDir config
by chengcyber · 2026-02-14
83.2%
#14944: fix(browser): prefer openclaw profile in headless/noSandbox environ...
by BenediktSchackenberg · 2026-02-12
74.7%
#15304: feat(browser): add browser-use no-relay profile driver
by rajanrengasamy · 2026-02-13
74.4%
#22952: fix(browser): suggest remote profile when local Chrome is not insta...
by dashed · 2026-02-21
74.3%
#13568: Fix browser (OpenClaw-managed) launch fail by binding remote debugg...
by singlag · 2026-02-10
73.0%
#9020: fix(browser): skip port ownership and WS reachability checks for re...
by yepack · 2026-02-04
72.8%
#6193: fix(browser): default to openclaw profile instead of chrome extensi...
by mikezaoldyeck · 2026-02-01
72.1%
#19966: feat: add language support for browser profiles
by cyfrit · 2026-02-18
71.5%
#8282: Fix: Enable browser downloads via CDP Browser.setDownloadBehavior
by vishaltandale00 · 2026-02-03
71.5%
#19495: fix: handle Chrome process re-parenting on Windows
by andenwick · 2026-02-17
70.5%