odysseus-dev/odysseus · error · HTTPException

Invalid query

Error message

Invalid query

What it means

Error "Invalid query" thrown in odysseus-dev/odysseus.

Source

Thrown at routes/email_routes.py:2792

        q: str = Query(""),
        folder: str = Query("INBOX"),
        limit: int = Query(50),
        account_id: str | None = Query(None),
        local_only: bool = Query(False),
        scope: str = Query("all"),
        owner: str = Depends(require_owner),
    ):
        """Search emails server-side via IMAP SEARCH. Matches subject, from, or body text.

        When the caller asks for INBOX and the account has an "All Mail"
        folder (Gmail does), we transparently swap to All Mail so the
        search surfaces archived / labelled emails too. Plain IMAP
        accounts fall back to whatever folder the caller specified."""
        if not q or len(q) < 2:
            return {"emails": [], "total": 0, "query": q}
        # CRLF in q would terminate the IMAP command early — reject defensively.
        if "\r" in q or "\n" in q:
            raise HTTPException(400, "Invalid query")
        global_search = (scope or "all").lower() != "folder"
        indexed_response = None
        try:
            indexed_emails, indexed_total, indexed_at = _email_index_search(owner, account_id, folder, q, limit, global_search=global_search)
            indexed_response = {
                "emails": indexed_emails,
                "total": indexed_total,
                "query": q,
                "folder": folder,
                "source": "index",
                "sync": {
                    "source": "index",
                    "updated_at": indexed_at,
                },
            }
            if local_only:
                return indexed_response

View on GitHub (pinned to f9235ebbf1)

Solutions

  1. Fix the search query syntax and retry.
  2. Remove unsupported operators or special characters from the query.

When it happens

Trigger: Triggered when the corresponding server-side validation or runtime check at the recorded location rejects the request or operation and returns this error message to the caller.

Common situations: See trigger scenarios.


AI-assisted analysis of odysseus-dev/odysseus@f9235ebbf1 (2026-08-14). Data as JSON: /api/errors/1d7b974932547831. Report an issue: GitHub.