{"record":{"id":"5f630423523182f4","repo":"BerriAI/litellm","slug":"unexpected-litellm-params-type-type-existing-par","errorCode":null,"errorMessage":"Unexpected litellm_params type: {type(existing_params)}","messagePattern":"Unexpected litellm_params type: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"litellm/proxy/management_endpoints/tag_management_endpoints.py","lineNumber":376,"sourceCode":"        raise HTTPException(status_code=500, detail=\"Database not connected\")\n\n    try:\n        # Get current model from database to preserve encrypted fields\n        db_model = await ModelRepository(prisma_client).table.find_unique(where={\"model_id\": deployment.model_info.id})\n\n        if db_model is None:\n            raise HTTPException(\n                status_code=404,\n                detail=f\"Model {deployment.model_info.id} not found in database\",\n            )\n\n        # Prisma returns litellm_params as dict (already parsed from JSON)\n        existing_params = db_model.litellm_params\n        if isinstance(existing_params, str):\n            # If it's a string, parse it\n            existing_params = json.loads(existing_params)\n        elif not isinstance(existing_params, dict):\n            raise Exception(f\"Unexpected litellm_params type: {type(existing_params)}\")\n\n        # Add tag to tags array (preserve encryption of other fields)\n        if \"tags\" not in existing_params:\n            existing_params[\"tags\"] = []\n        if tag not in existing_params[\"tags\"]:\n            existing_params[\"tags\"].append(tag)\n\n        # Update database with modified params (keeps encrypted fields encrypted)\n        await ModelRepository(prisma_client).table.update(\n            where={\"model_id\": deployment.model_info.id},\n            data={\"litellm_params\": json.dumps(existing_params)},\n        )\n    except Exception as e:\n        verbose_proxy_logger.exception(\"Error adding tag to deployment: %s\", e)\n        raise HTTPException(status_code=500, detail=str(e))\n\n\n@router.post(","sourceCodeStart":358,"sourceCodeEnd":394,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/management_endpoints/tag_management_endpoints.py#L358-L394","documentation":"The deployment's stored litellm_params came back from Prisma in an unexpected shape (not the dict the code expects), so merging the tag would risk corrupting the config; the helper raises 500 naming the actual type. At-fault condition is unexpected DB payload typing.","triggerScenarios":"Thrown at litellm/proxy/management_endpoints/tag_management_endpoints.py:376 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the model's litellm_params in the DB; it has an unexpected type. Re-create the model if corrupted."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}