{"record":{"id":"eb04859abc0ff349","repo":"lfnovo/open-notebook","slug":"error-syncing-all-models-str-e","errorCode":null,"errorMessage":"Error syncing all models: {str(e)}","messagePattern":"Error syncing all models: (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"api/routers/models.py","lineNumber":637,"sourceCode":"                discovered=discovered,\n                new=new,\n                existing=existing,\n            )\n            total_discovered += discovered\n            total_new += new\n\n        return AllProvidersSyncResponse(\n            results=response_results,\n            total_discovered=total_discovered,\n            total_new=total_new,\n        )\n    except HTTPException:\n        raise\n    except OpenNotebookError:\n        raise\n    except Exception as e:\n        logger.error(f\"Error syncing all models: {str(e)}\")\n        raise HTTPException(\n            status_code=500, detail=f\"Error syncing all models: {str(e)}\"\n        )\n\n\n@router.get(\"/models/count/{provider}\", response_model=ProviderModelCountResponse)\nasync def get_model_count(provider: str):\n    \"\"\"\n    Get count of registered models for a provider, grouped by type.\n\n    Returns counts for each model type (language, embedding,\n    speech_to_text, text_to_speech) as well as total count.\n    \"\"\"\n    try:\n        counts = await get_provider_model_count(provider)\n        total = sum(counts.values())\n        return ProviderModelCountResponse(\n            provider=provider,\n            counts=counts,","sourceCodeStart":619,"sourceCodeEnd":655,"githubUrl":"https://github.com/lfnovo/open-notebook/blob/a7de90d38aaf18ee85fd661854d35c11e44613e2/api/routers/models.py#L619-L655","documentation":"Generic 500 from POST /api/v1/models/sync (all providers) when the aggregate sync operation fails unexpectedly. Individual per-provider failures may be collected, but an unexpected exception in the orchestration or DB write lands here.","triggerScenarios":"POST /models/sync when any configured provider throws during sync and the code path does not isolate it, or when results cannot be persisted to the DB.","commonSituations":"One bad provider config breaking the whole sync; DB unavailable while writing synced models; missing API keys.","solutions":["Check API logs for 'Error syncing all models'","Run per-provider sync (POST /models/sync/{provider}) to identify the offender","Fix or remove the misconfigured provider and re-run full sync"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"const avail = await api.getProviderAvailability();\nconst good = Object.entries(avail).filter(([,v]) => v.available).map(([k]) => k);\nif (good.length === 0) throw new Error('no healthy providers');","typeGuard":null,"tryCatchPattern":"try { await api.syncAllModels(); } catch (e) { if (e.status === 500) { for (const p of providers) await safeSync(p); } }","preventionTips":["Sync per-provider to isolate failures","Fix bad provider configs before full sync","Fall back to per-provider sync on aggregate failure"],"tags":["models","sync","http-500"],"backgroundTag":"provider-api-request-failed","analyzedSha":"a7de90d38aaf18ee85fd661854d35c11e44613e2","analyzedAt":"2026-08-27T02:39:58.166Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}