{"record":{"id":"5432ad7d3a135913","repo":"langflow-ai/langflow","slug":"knowledge-base-missing-embedding-configuration-pl","errorCode":null,"errorMessage":"Knowledge base missing embedding configuration. Please create a new KB or reconfigure it.","messagePattern":"Knowledge base missing embedding configuration\\. Please create a new KB or reconfigure it\\.","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"src/backend/base/langflow/api/v1/knowledge_bases.py","lineNumber":1082,"sourceCode":"                column_config_parsed = json.loads(column_config)\n                if isinstance(column_config_parsed, list):\n                    # Update embedding_metadata.json\n                    cc_metadata_path = kb_path / \"embedding_metadata.json\"\n                    if cc_metadata_path.exists():\n                        existing_meta = json.loads(cc_metadata_path.read_text())\n                        existing_meta[\"column_config\"] = column_config_parsed\n                        cc_metadata_path.write_text(json.dumps(existing_meta, indent=2))\n                    # Write schema.json for text-metric helpers\n                    schema_data = [{**col, \"data_type\": \"string\"} for col in column_config_parsed]\n                    schema_path = kb_path / \"schema.json\"\n                    schema_path.write_text(json.dumps(schema_data, indent=2))\n            except (json.JSONDecodeError, TypeError):\n                await logger.awarning(\"Malformed column_config received, using existing schema\")\n\n        # 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","sourceCodeStart":1064,"sourceCodeEnd":1100,"githubUrl":"https://github.com/langflow-ai/langflow/blob/976ec789d2886a86de109c044d089d68e96c9a35/src/backend/base/langflow/api/v1/knowledge_bases.py#L1064-L1100","documentation":"A 400 raised by the file-upload ingest endpoint when KBAnalysisHelper.get_metadata(kb_path, fast=False) returns nothing for the target knowledge base directory. It means the KB on disk has no embedding configuration metadata, which can happen for a KB created without an embedding model or one whose metadata file was lost/corrupted. The fast=False call also runs legacy-KB migration/detection before giving up.","triggerScenarios":"POST /api/v1/knowledge_bases/{kb_name}/upload against a KB whose directory contains no readable embedding metadata (missing/corrupted metadata file, or a KB directory created without ever selecting an embedding model). Also possible if kb_name resolves to a directory the metadata reader cannot parse.","commonSituations":"Using a KB created before embedding config was mandatory, deleting or partially copying the KB folder on disk, failed prior KB creation that left an empty directory, or pointing at a KB name that maps to a stale directory.","solutions":["Recreate the knowledge base from the UI, explicitly selecting an embedding model and provider.","Reconfigure the existing KB (update embedding settings) so a valid metadata payload with model_selection/embedding_model is written to disk.","Inspect the KB directory on the server and confirm the metadata file exists and is valid JSON; restore it from backup if corrupted.","Verify kb_name matches an actually-created KB (GET /api/v1/knowledge_bases) and is not a leftover directory."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"async def kb_ready_for_ingest(client, kb_name: str) -> bool:\n    resp = await client.get(f\"/api/v1/knowledge_bases/{kb_name}\")\n    if resp.status_code != 200:\n        return False\n    meta = resp.json().get(\"embedding_config\") or {}\n    return bool(meta)","typeGuard":null,"tryCatchPattern":"try:\n    resp = await client.post(upload_url, files=files)\nexcept HTTPError as e:\n    if e.response.status_code == 400 and \"missing embedding configuration\" in e.response.text:\n        # recreate/reconfigure KB, then retry once\n        ...","preventionTips":["Always create KBs with an explicit embedding model and provider selected.","Health-check a KB (GET /{kb_name}) before large ingestion runs.","Back up the KB metadata file alongside the KB directory."],"tags":["knowledge-base","embedding","metadata","http-400"],"backgroundTag":null,"analyzedSha":"976ec789d2886a86de109c044d089d68e96c9a35","analyzedAt":"2026-08-14T18:23:12.227Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}