HKUDS/DeepTutor · error · HTTPException

Both name and agent_kind are required.

Error message

Both name and agent_kind are required.

What it means

The create-connection endpoint requires both a non-empty name and agent_kind in the JSON payload; whitespace-only or missing values are rejected with 400 before any backend lookup.

Source

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

                "updated_at": meta.get("updated_at"),
            }
        )
    return {"connections": connections}


@router.post("/connections")
async def create_connection(payload: ConnectSubagentRequest):
    """Connect a subagent (a local CLI, or one of the user's partners) as a selectable KB.

    A partner connection (``agent_kind == "partner"``) binds a ``partner_id``
    instead of a working directory: consulting it opens a fresh session on that
    partner, exactly as if the user started one from the partner page. Every
    consult within one DeepTutor chat lands in that one partner session.
    """
    name = (payload.name or "").strip()
    agent_kind = (payload.agent_kind or "").strip()
    if not name or not agent_kind:
        raise HTTPException(status_code=400, detail="Both name and agent_kind are required.")
    if agent_kind not in list_backend_kinds():
        raise HTTPException(status_code=400, detail=f"Unknown agent kind: {agent_kind!r}")

    resolved_cwd = ""
    partner_id = ""
    if agent_kind == PARTNER_BACKEND_KIND:
        partner_id = (payload.partner_id or "").strip()
        if not partner_id:
            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

View on GitHub (pinned to 3e82f13042)

Solutions

  1. Fill both name and agent_kind with non-blank values
  2. Trim inputs client-side before POST
  3. Check the request payload actually serializes both fields

Example fix

// before
{"name": "  ", "agent_kind": "opencode"}
// after
{"name": "my-agent", "agent_kind": "opencode"}
Defensive patterns

Strategy: validation

Validate before calling

const name = rawName.trim();
const kind = rawKind.trim();
if (!name || !kind) return; // don't send
await fetch('/connections', {method:'POST', body: JSON.stringify({name, agent_kind: kind})});

Type guard

const isValidConnectionPayload = (p: any): p is {name:string; agent_kind:string} =>
  typeof p?.name === 'string' && p.name.trim() !== '' &&
  typeof p?.agent_kind === 'string' && p.agent_kind.trim() !== '';

Try / catch

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

Prevention

When it happens

Trigger: POST /connections with {"name":""}, {"agent_kind":" "}, or either field omitted/null.

Common situations: Frontend form submitted before user fills both fields; whitespace sneaking in from a trimmed-elsewhere input; payload built with undefined JS variables.

Understand the failure class

Background: "Missing required field" and "field is required" errors: why libraries reject payloads that omit mandatory fields — this error's family across 20 libraries.

Related errors


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