Spot the bug in the CLI wrapper

from AI coding CLIs
Python 3.14 intermediate 6 min 3 issues to find

Find the boundary and evidence bugs in this generated wrapper.

Python
from pathlib import Path
import subprocess

ROOT = Path("/srv/project")

def ask_cli(relative_path: str, task: str) -> str:
    target = (ROOT / relative_path).resolve()
    if not str(target).startswith(str(ROOT)):
        raise PermissionError(target)

    command = f'ai-cli "Edit {target}: {task}"'
    completed = subprocess.run(
        command, shell=True, capture_output=True, text=True
    )
    return completed.stdout
Open in playground
Report an error