HKUDS/DeepTutor · error · HTTPException

{exc}

Error message

{exc}

What it means

For non-partner connections, an optional cwd must pass assert_path_allowed(); a ValueError (path outside allowed roots, nonexistent, or not a directory) is surfaced as 400 with the original message.

Source

Thrown at deeptutor/api/routers/subagents.py:171

            raise HTTPException(
                status_code=400, detail="A partner_id is required to connect a partner."
            )
        # Partners are admin-managed, but an admin can assign one to a user via
        # the grant system. An admin may connect any partner; a non-admin only a
        # partner assigned to them (403 otherwise). The partner still runs in its
        # own isolated scope — connecting just lets the user consult it in chat.
        assert_partner_allowed(partner_id)
        from deeptutor.services.partners import get_partner_manager

        if not get_partner_manager().partner_exists(partner_id):
            raise HTTPException(status_code=400, detail=f"No partner named {partner_id!r}.")
    else:
        raw_cwd = (payload.cwd or "").strip()
        if raw_cwd:
            try:
                resolved_cwd = str(assert_path_allowed(raw_cwd))
            except ValueError as exc:
                raise HTTPException(status_code=400, detail=str(exc)) from exc

    try:
        manager = current_kb_manager()
        entry = manager.register_subagent_connection(
            name, agent_kind, cwd=resolved_cwd, partner_id=partner_id
        )
    except ValueError as exc:
        raise HTTPException(status_code=400, detail=str(exc)) from exc
    except Exception as exc:  # pragma: no cover - defensive
        logger.error("Error connecting subagent: %s", exc)
        raise HTTPException(status_code=500, detail=str(exc)) from exc

    return {
        "status": "connected",
        "name": name,
        "agent_kind": entry["agent_kind"],
        "cwd": entry["cwd"],
        "partner_id": entry.get("partner_id", ""),

View on GitHub (pinned to 3e82f13042)

Solutions

  1. Use a path under an allowed root (e.g. the workspace/project dir)
  2. Check the allowed-paths configuration for the server
  3. Omit cwd entirely if you don't need to scope the agent to a directory

Example fix

// before
{"cwd": "/etc/ssl"}
// after
{"cwd": "/home/me/projects/my-repo"}
Defensive patterns

Strategy: validation

Validate before calling

const resp = await fetch('/api/v1/system/allowed-paths'); // or use known workspace root
const cwd = pathInsideWorkspace(userPath, workspaceRoot);
if (!cwd) { showPathError(); return; }

Type guard

const isAllowedPath = (p: string) => p.startsWith(WORKSPACE_ROOT + '/');

Try / catch

try { await createConnection(p); } catch (e) { if (e.status === 400) showPathError(e.detail); }

Prevention

When it happens

Trigger: POST /connections with cwd like "/etc" or any path outside the configured allowed roots, or a path that cannot be resolved.

Common situations: Users entering arbitrary absolute paths; sandbox/allowlist tightened after the client was written; relative path resolved against an unexpected cwd.

Related errors


AI-assisted analysis of HKUDS/DeepTutor@3e82f13042 (2026-08-27). Data as JSON: /api/errors/4ce1830bc78ab08b. Report an issue: GitHub.