Skip to content

fix(cli): return failure when init cannot write its template - #6061

Open
Aurantium-47 wants to merge 3 commits into
browser-use:mainfrom
Aurantium-47:codex/fix-init-write-errors
Open

Aurantium-47 wants to merge 3 commits into
browser-use:mainfrom
Aurantium-47:codex/fix-init-write-errors

Conversation

@Aurantium-47

@Aurantium-47 Aurantium-47 commented Oct 14, 2026 •

Copy link
Copy Markdown

When browser-use init cannot write the main template file, it prints an error but exits with status 0. If the output path is an existing directory, a setup script sees a successful command even though no script was created.

Raise Click's ClickException for write errors so the command exits with status 1 and retains the filesystem error message. Declining an overwrite keeps its existing behavior, and failures for additional manifest files still use the existing warning path.

Reproduction on Windows, using a local HTTP template fixture with demo/main.py already a directory:

browser-use init --template demo --force

Before: Error writing file: [Errno 13] Permission denied: .../demo/main.py
        exit status 0
After:  Error: Error writing file: [Errno 13] Permission denied: .../demo/main.py
        exit status 1

Validation:

  • Four regression cases using a local HTTP template server and real files: write failure, new file, forced overwrite, and declined overwrite. The failure case fails before the change; all four pass afterward.
  • Existing CLI tests: four passed.
  • Separate review ran nine real-I/O scenarios against both the original and patched source, including custom output paths, auxiliary-file errors and template download errors; all 18 checks passed.
  • All applicable pre-commit hooks passed for both changed files, including the pinned Ruff and Pyright checks.

AI assistance: OpenAI Codex investigated the issue, wrote the patch and tests, and prepared this description. A separate Codex agent reviewed the change and ran the additional checks.


Summary by cubic

Fixes browser-use init so a failure to write the main template file now exits with status 1 instead of 0. Previously the command printed an error but reported success, which could mislead setup scripts when the output path was an existing directory.

Declining an overwrite keeps its existing behavior, and errors on auxiliary manifest files still use the warning path. Adds regression tests covering write failure, successful write, forced overwrite, and declined overwrite, and verifies the failure error message includes the target filename.

Written for commit 1d4165b. Summary will update on new commits.

View guided diff

Assisted-by: OpenAI Codex (model: gpt-6-astra, autonomous)
@CLAassistant

CLAassistant commented Oct 14, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 2 files

Reply to a comment to ask cubic a question or push back. It learns from your replies.
Click Fix with cubic on a comment, or reply @cubic-dev-ai fix this, and cubic writes the fix.

View guided diff | Re-trigger cubic

Comment thread tests/ci/test_init_cmd.py Resolved
@mintlify

mintlify Bot commented Oct 31, 2026

Copy link
Copy Markdown

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit 1d4165b.

Approve preview

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants