Skip to content

fix: remove unreachable absolute path check in CLI run command#405

Open
hobostay wants to merge 1 commit intobytedance:mainfrom
hobostay:fix/remove-dead-code-absolute-path-check
Open

fix: remove unreachable absolute path check in CLI run command#405
hobostay wants to merge 1 commit intobytedance:mainfrom
hobostay:fix/remove-dead-code-absolute-path-check

Conversation

@hobostay
Copy link
Copy Markdown

Summary

  • Remove dead code in cli.py:345-350 that checks if working_dir is an absolute path but can never be reached

Problem

In the run() command, the block:

if not Path(working_dir).is_absolute():
    console.print(
        f"[red]Working directory must be an absolute path: {working_dir}, it should start with `/`[/red]"
    )
    sys.exit(1)

is unreachable because both code branches above guarantee an absolute path:

  • When working_dir is provided: os.path.abspath(working_dir) on line 336 always returns an absolute path
  • When working_dir is not provided: os.getcwd() on line 342 always returns an absolute path

This error message could never actually be displayed to the user.

Fix

Removed the unreachable block.

Test plan

  • Verify trae run "task" --working-dir ./relative still works (abspath handles it)
  • Verify trae run "task" without working-dir still works (uses cwd)

🤖 Generated with Claude Code

The check `if not Path(working_dir).is_absolute()` on line 346 is dead
code because both branches above guarantee an absolute path:
- Line 336: `working_dir = os.path.abspath(working_dir)` always returns
  an absolute path
- Line 342: `working_dir = os.getcwd()` always returns an absolute path

The error message on line 348 could never be displayed. Remove the
unreachable block.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Test User seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

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