{"record":{"id":"1d7b974932547831","repo":"odysseus-dev/odysseus","slug":"invalid-query","errorCode":null,"errorMessage":"Invalid query","messagePattern":"Invalid query","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"routes/email_routes.py","lineNumber":2792,"sourceCode":"        q: str = Query(\"\"),\n        folder: str = Query(\"INBOX\"),\n        limit: int = Query(50),\n        account_id: str | None = Query(None),\n        local_only: bool = Query(False),\n        scope: str = Query(\"all\"),\n        owner: str = Depends(require_owner),\n    ):\n        \"\"\"Search emails server-side via IMAP SEARCH. Matches subject, from, or body text.\n\n        When the caller asks for INBOX and the account has an \"All Mail\"\n        folder (Gmail does), we transparently swap to All Mail so the\n        search surfaces archived / labelled emails too. Plain IMAP\n        accounts fall back to whatever folder the caller specified.\"\"\"\n        if not q or len(q) < 2:\n            return {\"emails\": [], \"total\": 0, \"query\": q}\n        # CRLF in q would terminate the IMAP command early — reject defensively.\n        if \"\\r\" in q or \"\\n\" in q:\n            raise HTTPException(400, \"Invalid query\")\n        global_search = (scope or \"all\").lower() != \"folder\"\n        indexed_response = None\n        try:\n            indexed_emails, indexed_total, indexed_at = _email_index_search(owner, account_id, folder, q, limit, global_search=global_search)\n            indexed_response = {\n                \"emails\": indexed_emails,\n                \"total\": indexed_total,\n                \"query\": q,\n                \"folder\": folder,\n                \"source\": \"index\",\n                \"sync\": {\n                    \"source\": \"index\",\n                    \"updated_at\": indexed_at,\n                },\n            }\n            if local_only:\n                return indexed_response\n","sourceCodeStart":2774,"sourceCodeEnd":2810,"githubUrl":"https://github.com/odysseus-dev/odysseus/blob/f9235ebbf13f693a6fd29ce70b097f6ec83705bf/routes/email_routes.py#L2774-L2810","documentation":"Error \"Invalid query\" thrown in odysseus-dev/odysseus.","triggerScenarios":"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.","commonSituations":"See trigger scenarios.","solutions":["Fix the search query syntax and retry.","Remove unsupported operators or special characters from the query."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f9235ebbf13f693a6fd29ce70b097f6ec83705bf","analyzedAt":"2026-08-14T21:47:48.359Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}