HKUDS/nanobot · error · CliAppError

invalid command

Error message

invalid command: {exc}

What it means

Raised by _split_safe_command when shlex.split of the stored command raises — the command string is malformed (unbalanced quotes or invalid tokenization) and cannot be converted to an argv list safely.

Solutions

  1. Fix the quoting in the catalog entry's command string
  2. Replace the entry with a well-formed plain command
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at nanobot/apps/cli/service.py:963 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of HKUDS/nanobot@42f37dc4c0 (2026-08-26). Data as JSON: /api/errors/36ba505b8554df6b. Report an issue: GitHub.

Appendix: source

Thrown at nanobot/apps/cli/service.py:963

        result: subprocess.CompletedProcess[str],
    ) -> subprocess.CompletedProcess[str]:
        output = f"{result.stderr}\n{result.stdout}"
        if "ENOTEMPTY" not in output or "rename" not in output:
            return result
        if not self._cleanup_stale_npm_install(app):
            return result
        return self._run_argv(argv, timeout=self.runtime.install_timeout)

    def _split_safe_command(self, app: dict[str, Any], key: str, expected: str) -> list[str]:
        command = str(app.get(key) or "")
        if not command:
            raise CliAppError(f"no {key} is defined for {app['name']}")
        if _has_shell_meta(command):
            raise CliAppError("script-style install commands are disabled in this MVP")
        try:
            argv = shlex.split(command)
        except ValueError as exc:
            raise CliAppError(f"invalid command: {exc}") from exc
        if not argv or argv[0] != expected:
            raise CliAppError(f"unsupported {expected} command")
        return argv

    def _argv_for_action(
        self,
        app: dict[str, Any],
        action: str,
        installed_entry: dict[str, Any] | None = None,
    ) -> list[str] | None:
        strategy = self._strategy(app)
        if strategy == "pip":
            if action == "install":
                return self._pip_install_argv(app)
            if action == "update":
                return self._pip_install_argv(app, update=True)
            return self._pip_uninstall_argv(app, installed_entry=installed_entry)
        if strategy == "npm":

View on GitHub (pinned to 42f37dc4c0)