HKUDS/nanobot · error · CliAppError

working_dir is outside the configured workspace

Error message

working_dir is outside the configured workspace

What it means

Raised by _resolve_cwd when a caller-supplied working_dir resolves outside the configured workspace while restrict_to_workspace is active. It is the path-containment guard for CLI app execution; commands must run inside the workspace.

Solutions

  1. Use a working_dir inside the workspace (relative paths are safest)
  2. Disable the workspace restriction only if the configuration explicitly allows it
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at nanobot/apps/cli/service.py:1347 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/df000d986d0b7ffd. Report an issue: GitHub.

Appendix: source

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

        return self.payload() | {
            "last_action": {
                "ok": ok,
                "message": f"{entry} --help exited {result.returncode}",
                "output": output,
            }
        }

    def _resolve_cwd(
        self,
        working_dir: str | None,
        *,
        restrict_to_workspace: bool,
    ) -> Path:
        cwd = Path(working_dir).expanduser() if working_dir else self.workspace
        cwd = cwd.resolve(strict=False)
        workspace = self.workspace.resolve(strict=False)
        if restrict_to_workspace and not is_path_within(cwd, workspace):
            raise CliAppError("working_dir is outside the configured workspace")
        return cwd

    def _iter_artifact_candidates(self, cwd: Path) -> list[Path]:
        if not cwd.is_dir():
            return []
        out: list[Path] = []
        stack = [cwd]
        scanned = 0
        while stack and scanned < _MAX_ARTIFACT_SCAN_PATHS:
            directory = stack.pop()
            try:
                entries = sorted(directory.iterdir(), key=lambda path: path.name.lower())
            except OSError:
                continue
            for path in entries:
                if scanned >= _MAX_ARTIFACT_SCAN_PATHS:
                    break
                scanned += 1

View on GitHub (pinned to 42f37dc4c0)