{"record":{"id":"697d57d9d3e66a51","repo":"langflow-ai/langflow","slug":"invalid-embedding-configuration","errorCode":null,"errorMessage":"Invalid embedding configuration","messagePattern":"Invalid embedding configuration","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"src/backend/base/langflow/api/v1/knowledge_bases.py","lineNumber":1097,"sourceCode":"        # Read embedding metadata (Pass fast=False to ensure legacy KBs are migrated/detected)\n        metadata = KBAnalysisHelper.get_metadata(kb_path, fast=False)\n        if not metadata:\n            raise HTTPException(\n                status_code=400,\n                detail=\"Knowledge base missing embedding configuration. Please create a new KB or reconfigure it.\",\n            )\n\n        # ``model_selection`` is the canonical embedding-config payload.\n        # Synthesize it from the legacy flat metadata fields when older\n        # KBs only carry those (``record_to_metadata_dict`` writes both\n        # forms for new KBs, so this branch is mainly for disk-only\n        # ones that haven't been backfilled yet).\n        model_selection = metadata.get(\"model_selection\") or {\n            \"name\": metadata.get(\"embedding_model\"),\n            \"provider\": metadata.get(\"embedding_provider\"),\n        }\n        if not model_selection.get(\"name\") or not model_selection.get(\"provider\"):\n            raise HTTPException(status_code=400, detail=\"Invalid embedding configuration\")\n\n        # Use ``KnowledgeBaseRecord.id`` (when present) as the Job's\n        # ``asset_id`` so the read path can hit the indexed\n        # ``Job.asset_id`` column instead of doing a JSON-extract on\n        # ``Job.job_metadata.kb_name``. Falls back to legacy\n        # ``metadata['id']`` for KBs that exist on disk only.\n        asset_id = await _resolve_kb_asset_id(\n            kb_name=kb_name,\n            current_user=current_user,\n            metadata=metadata,\n        )\n\n        # Get services and create job before async/sync split\n        job_service = get_job_service()\n        job_id = uuid.uuid4()\n\n        # Create job record in database for both async and sync paths\n        await job_service.create_job(","sourceCodeStart":1079,"sourceCodeEnd":1115,"githubUrl":"https://github.com/langflow-ai/langflow/blob/976ec789d2886a86de109c044d089d68e96c9a35/src/backend/base/langflow/api/v1/knowledge_bases.py#L1079-L1115","documentation":"A 400 raised after metadata is loaded: the embedding config payload (model_selection, or the legacy embedding_model/embedding_provider fields) lacks a name or a provider. The KB exists and has metadata, but the embedding configuration recorded on it is incomplete, so ingestion cannot proceed because embeddings cannot be resolved.","triggerScenarios":"POST /api/v1/knowledge_bases/{kb_name}/upload where the KB metadata exists but model_selection.name or model_selection.provider is empty/missing AND the legacy embedding_model/embedding_provider fallbacks are also empty. Typically hand-edited metadata or a partially written KB config.","commonSituations":"Manually edited or migrated KB metadata files, a KB created against an older version whose creation flow did not persist provider, or a metadata write interrupted midway.","solutions":["Reconfigure the KB's embedding settings via the UI/API so both model name and provider are persisted.","Recreate the KB and re-ingest its files.","Fix the metadata file on disk directly: ensure model_selection = {\"name\": ..., \"provider\": ...} is complete.","If this repros for newly created KBs, check for a version mismatch between frontend creation flow and backend expectations and update Langflow."],"exampleFix":"# repair on-disk metadata\nimport json, pathlib\np = pathlib.Path(kb_dir) / \"metadata\"  # location of KB metadata\nmeta = json.loads(p.read_text())\nmeta[\"model_selection\"] = {\"name\": \"openai/text-embedding-3-small\", \"provider\": \"openai\"}\np.write_text(json.dumps(meta))","handlingStrategy":"validation","validationCode":"def has_complete_embedding_config(metadata: dict) -> bool:\n    sel = metadata.get(\"model_selection\") or {\n        \"name\": metadata.get(\"embedding_model\"),\n        \"provider\": metadata.get(\"embedding_provider\"),\n    }\n    return bool(sel.get(\"name\") and sel.get(\"provider\"))","typeGuard":"from typing import TypedDict\n\nclass ModelSelection(TypedDict, total=False):\n    name: str\n    provider: str\n\ndef is_valid_model_selection(ms: dict) -> bool:\n    return isinstance(ms, dict) and bool(ms.get(\"name\")) and bool(ms.get(\"provider\"))","tryCatchPattern":"try:\n    await ingest(files)\nexcept HTTPStatusError as e:\n    if e.response.status_code == 400:\n        detail = e.response.json()[\"detail\"]\n        if detail == \"Invalid embedding configuration\":\n            await reconfigure_kb_embedding(kb, model, provider)","preventionTips":["Never hand-edit KB metadata without keeping model_selection complete.","After reconfiguring a KB, run a one-file smoke ingestion to confirm the config took.","Treat missing provider as a creation-time bug and upgrade if new KBs repro it."],"tags":["knowledge-base","embedding","configuration","http-400"],"backgroundTag":null,"analyzedSha":"976ec789d2886a86de109c044d089d68e96c9a35","analyzedAt":"2026-08-14T18:23:12.227Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}