{"record":{"id":"2d463fc7883f857e","repo":"lfnovo/open-notebook","slug":"error-auto-assigning-defaults-str-e","errorCode":null,"errorMessage":"Error auto-assigning defaults: {str(e)}","messagePattern":"Error auto-assigning defaults: (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"api/routers/models.py","lineNumber":846,"sourceCode":"                setattr(defaults, slot_name, model_id)\n\n        # Save updated defaults if any assignments were made\n        if assigned:\n            await defaults.update()\n\n        return AutoAssignResult(\n            assigned=assigned,\n            skipped=skipped,\n            missing=missing,\n        )\n\n    except HTTPException:\n        raise\n    except OpenNotebookError:\n        raise\n    except Exception as e:\n        logger.error(f\"Error auto-assigning defaults: {str(e)}\")\n        raise HTTPException(\n            status_code=500, detail=f\"Error auto-assigning defaults: {str(e)}\"\n        )\n","sourceCodeStart":828,"sourceCodeEnd":849,"githubUrl":"https://github.com/lfnovo/open-notebook/blob/a7de90d38aaf18ee85fd661854d35c11e44613e2/api/routers/models.py#L828-L849","documentation":"Generic 500 from the auto-assign defaults endpoint when automatically assigning default models fails. The handler ranks discovered models per provider priority; unexpected exceptions during discovery, ranking, or the defaults update land here.","triggerScenarios":"POSTing auto-assign when no providers are configured/discoverable, when discovery raises unexpectedly, or when writing defaults fails (DB error).","commonSituations":"Fresh install with no API keys so discovery returns garbage or throws; DB unavailable; conflicting concurrent defaults update.","solutions":["Check API logs for 'Error auto-assigning defaults'","Ensure at least one provider is configured with valid credentials","Run discovery/sync manually first (POST /models/sync) to confirm it works","Retry auto-assign after fixing the underlying provider issue"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const avail = await api.getProviderAvailability();\nif (!Object.values(avail).some(v => v.available)) throw new Error('configure a provider first');","typeGuard":null,"tryCatchPattern":"try { await api.autoAssignDefaults(); } catch (e) { if (e.status === 500) { await syncProviders(); await retryOnce(); } }","preventionTips":["Configure at least one working provider before auto-assign","Run manual sync first to verify discovery works","Review server logs for the root cause"],"tags":["models","defaults","http-500"],"backgroundTag":"internal-server-error","analyzedSha":"a7de90d38aaf18ee85fd661854d35c11e44613e2","analyzedAt":"2026-08-27T02:39:58.166Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}