Skip to content

[BUG] Direct SQLite Bypass in Admin API, CLI, and MCP #37

@sandy4242

Description

@sandy4242

Describe the Bug

The Admin API endpoints, CLI query tools hp escalations/hp session, and the MCP tool list_recent_escalations bypass the active swappable storage backend (Postgres/Redis) and query a local SQLite database directly using sqlite3.connect().

To Reproduce

Steps to reproduce the behaviour:

  1. Configure humane_proxy.yaml to use a non-default storage backend:
    storage:
      backend: "redis"
      redis:
        url: "redis://localhost:6379/0"
  2. Log an escalation .
  3. The escalation is correctly logged to Redis.
  4. Run the query CLI tool: hp escalations (or query GET /admin/escalations).
  5. Observe that the returned list is empty because the CLI/API is querying a local SQLite escalations.db file instead of the configured Redis store.

Expected Behaviour

The Admin API, CLI, and MCP server should query the active storage backend using the swappable storage factory (get_store()) instead of opening direct, hardcoded SQLite connections.

Actual Behaviour

The API (admin.py), CLI (cli.py), and MCP Server (mcp_server.py) import sqlite3 and call sqlite3.connect() directly to retrieve escalations, calculate statistics, and delete session logs.

Environment

  • OS: (e.g. Ubuntu 22.04, Windows 11, macOS 14)
  • Python version: (e.g. 3.11.5)
  • HumaneProxy version: (run humane-proxy version)
  • Install extras: (e.g. [ml], [mcp], [all], or none)

Metadata

Metadata

Labels

backendIssues involving server-side logic, databases, or APIsbugSomething isn't workinglevel:criticalIrrespective of difficulty, core work for the projecttype:bugSmashes annoying bugs

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions