ComposioHQ/composio · error · ValidationError

Invalid tool router session delete response

Error message

Invalid tool router session delete response

What it means

After a successful HTTP delete of a tool-router session, the SDK validates the JSON response: it must contain a string session_id and deleted is exactly True. If either check fails (unexpected response shape, backend returning an error object with 200, or deleted=False), this ValidationError is raised.

Source

Thrown at python/composio/core/models/tool_router_session_delete.py:34

    session_id: str
    deleted: t.Literal[True]


def delete_tool_router_session(
    client: HttpClient,
    session_id: str,
) -> ToolRouterSessionDeleteResponse:
    """Delete a tool router session by ID."""
    response = client.delete(
        f"/api/v3.1/tool_router/session/{quote(session_id, safe='')}",
        cast_to=t.Dict[str, t.Any],
    )

    response_session_id = response.get("session_id")
    deleted = response.get("deleted")
    if not isinstance(response_session_id, str) or deleted is not True:
        raise ValidationError("Invalid tool router session delete response")

    return {
        "session_id": response_session_id,
        "deleted": True,
    }

View on GitHub (pinned to 64b1b85502)

Solutions

  1. Check e.__cause__/logs to see the raw response body
  2. Upgrade composio to align with the current backend delete response
  3. Treat already-deleted sessions as success in your wrapper if idempotency matters

Example fix

# before
router.sessions.delete(sid)

# after
try:
    router.sessions.delete(sid)
except ValidationError:
    logger.warning('session %s may already be deleted', sid)
Defensive patterns

Strategy: try-catch

Try / catch

try:
    deleted = sessions.delete(sid)
except ValidationError:
    logger.warning('session %s delete response invalid; treating as gone', sid)
    deleted = {'session_id': sid, 'deleted': False}

Prevention

When it happens

Trigger: Deleting a session whose ID is already gone but the backend returns 200 with a non-conforming body; or backend/SDK response-schema drift after an API change.

Common situations: Version skew between composio SDK and backend, idempotent delete endpoints that return a different payload for missing sessions.

Related errors


AI-assisted analysis of ComposioHQ/composio@64b1b85502 (2026-08-28). Data as JSON: /api/errors/ffe5a6f4e2b0789d. Report an issue: GitHub.