Repository navigation
fix(tools): never delete a user-supplied browser profile dir on close() - #4713
all-hands-bot wants to merge 2 commits into
Conversation
PR #4602 made close() rmtree the user_data_dir whenever its path contains the substring "browseruse/profiles/", to reclaim the auto-generated profile dir. But a user who explicitly supplies their own persistent profile dir (kept for logins/cookies) whose path happens to contain that substring has it silently deleted on close() -> data loss. Track ownership of the profile dir instead: only delete it when this executor generated it (i.e. user_data_dir was not passed through config). Co-authored-by: openhands <openhands@all-hands.dev>
Python API breakage checks — ✅ PASSEDResult: ✅ PASSED |
REST API breakage checks (OpenAPI) — ✅ PASSEDResult: ✅ PASSED |
Co-authored-by: openhands <openhands@all-hands.dev>
Coverage Report •
|
||||||||||||||||||||
|
👋 This PR needs a couple of things fixed before OpenHands can review it:
Push an update once this is addressed and this check re-runs automatically. This is an automated check - no AI was used to generate this comment. |
|
Required CI has remained failing for seven days. Please repair it or comment with an update. If the author does not push or comment and required CI remains failing for another seven days, this pull request will be closed automatically. |
3 similar comments
|
Required CI has remained failing for seven days. Please repair it or comment with an update. If the author does not push or comment and required CI remains failing for another seven days, this pull request will be closed automatically. |
|
Required CI has remained failing for seven days. Please repair it or comment with an update. If the author does not push or comment and required CI remains failing for another seven days, this pull request will be closed automatically. |
|
Required CI has remained failing for seven days. Please repair it or comment with an update. If the author does not push or comment and required CI remains failing for another seven days, this pull request will be closed automatically. |
HUMAN:
AGENT:
Why
Source PR reviewed: #4602 (
fix(tools): unique user_data_dir per conversation to prevent SingletonLock collisions).Applicable risk lens: #1 (Boundary contracts and alternate valid inputs) and #10 (Negative-space / silent-success cases).
PR #4602 made
close()callshutil.rmtree(self._config["user_data_dir"])whenever the path contains the substring"browseruse/profiles/". The intent was to reclaim the auto-generated profile directory (~/.config/browseruse/profiles/<uuid>) that browser_use leaves behind on shutdown. But the guard is a substring match, not an ownership check: any user who explicitly supplies their own persistentuser_data_dir(e.g. to keep logins/cookies across sessions) whose path happens to containbrowseruse/profiles/will have that directory silently deleted onclose()— permanent data loss.Deterministic reproduction (probe run against
main):Impact: user-supplied browser profile directories (containing cookies, logins, bookmarks) are irrecoverably deleted when the conversation ends.
Summary
user_data_dirwas not passed via**config).close()now deletesuser_data_dironly when the executor owns it, instead of using a fragile"browseruse/profiles/" in pathsubstring match.REST API contract changes
Compared with base OpenAPI
9d143aac35c2for public/api/**paths.Issue Number
Fixes #4602
How to Test
Before (unmodified
main) — the regression test fails:After (this PR) — the regression test and full cleanup suite pass:
Root cause: the substring guard
"browseruse/profiles/" in user_data_dirconflates the auto-generated default path with any user-supplied path containing the same substring. The PR's own test only covered an override at/tmp/my-custom-browser-profile, which does not contain the substring, so the destructive branch was never exercised.Why the original tests did not catch this: the added test asserted the user-supplied path survived but used a path that lacked the magic substring, so the destructive
rmtreebranch was never reached.Video/Screenshots
No UI. Reproduction output captured above (probe on
mainprintsmarker exists after close(): False; with the fix it printsTrue).Design Doc
N/A
Type
Notes
neubig(author of fix(tools): unique user_data_dir per conversation to prevent SingletonLock collisions #4602). The approver of fix(tools): unique user_data_dir per conversation to prevent SingletonLock collisions #4602 isall-hands-bot(a bot), so no human approver is available to add.🐳 Agent Server images for this PR — GHCR package, pull/run commands, and all pushed tags (click to expand)
• GHCR package: https://github.com/OpenHands/agent-sdk/pkgs/container/agent-server
Variants & Base Images
eclipse-temurin:17-jdknikolaik/python-nodejs:python3.13-nodejs22-slimnikolaik/python-nodejs:python3.13-nodejs22-slimgolang:1.21-bookwormPull (multi-arch manifest)
# Each variant is a multi-arch manifest supporting both amd64 and arm64 docker pull ghcr.io/openhands/agent-server:e2001c1-pythonRun
All tags pushed for this build
About Multi-Architecture Support
e2001c1-python) is a multi-arch manifest supporting both amd64 and arm64e2001c1-python-amd64) are also available if neededJev-Fast-Audit
⚡ Jev fast audit · estimates · 0.28s · commit e2001c1
Strongest signal: No primary concern selected.
Evidence: No primary concern to locate.
Coverage: complete supplied coverage; 6/6 hunks, 3/3 files.
All estimates and evidence