{"record":{"id":"ed72efd817d10192","repo":"odysseus-dev/odysseus","slug":"auto-sort-failed-str-e","errorCode":null,"errorMessage":"Auto-sort failed: {str(e)}","messagePattern":"Auto-sort failed: (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":502,"severity":"error","filePath":"routes/session_routes.py","lineNumber":1265,"sourceCode":"            # Markdown code fence\n            if result is None:\n                fence_match = re.search(r'```(?:json)?\\s*\\n?([\\s\\S]*?)```', text)\n                if fence_match:\n                    result = _loads_lenient(fence_match.group(1).strip())\n            # First { … last } block\n            if result is None:\n                brace_start = text.find('{')\n                brace_end = text.rfind('}')\n                if brace_start >= 0 and brace_end > brace_start:\n                    result = _loads_lenient(text[brace_start:brace_end + 1])\n            if result is None:\n                logger.error(f\"Auto-sort: could not parse JSON from: {text[:500]}\")\n                raise HTTPException(502, \"AI returned invalid JSON for auto-sort — the model may not follow JSON instructions; try a different utility model in Settings.\")\n        except HTTPException:\n            raise\n        except Exception as e:\n            logger.error(f\"Auto-sort LLM call failed: {e}\")\n            raise HTTPException(502, f\"Auto-sort failed: {str(e)}\")\n\n        folders = result.get(\"folders\", {})\n        if not folders:\n            return {\"status\": \"skipped\", \"reason\": \"AI found no groupings\"}\n\n        # Build id -> folder map\n        id_prefix_map = {s[\"id\"][:8]: s[\"id\"] for s in session_list}\n        assignments = {}\n        for folder_name, ids in folders.items():\n            for sid_or_prefix in ids:\n                # Match by full ID or prefix\n                full_id = None\n                if sid_or_prefix in id_prefix_map.values():\n                    full_id = sid_or_prefix\n                else:\n                    # Try prefix match\n                    prefix = sid_or_prefix.rstrip(\".\").rstrip(\" \")\n                    if prefix in id_prefix_map:","sourceCodeStart":1247,"sourceCodeEnd":1283,"githubUrl":"https://github.com/odysseus-dev/odysseus/blob/f9235ebbf13f693a6fd29ce70b097f6ec83705bf/routes/session_routes.py#L1247-L1283","documentation":"Error \"Auto-sort failed: {str(e)}\" 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":["Check server logs for the underlying auto-sort error.","Verify the utility model endpoint is reachable and retry."],"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-15T17:31:12.345Z"}