{"record":{"id":"085dba726307755a","repo":"mem0ai/mem0","slug":"insert-operation-failed-response-status-error","errorCode":null,"errorMessage":"Insert operation failed: {response.status.error}","messagePattern":"Insert operation failed: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"mem0/vector_stores/databricks.py","lineNumber":458,"sourceCode":"\n        insert_sql = f\"INSERT INTO {self.fully_qualified_table_name} ({', '.join(self.column_names)}) VALUES {', '.join(value_tuples)}\"\n\n        # Execute the insert\n        try:\n            response = self.client.statement_execution.execute_statement(\n                statement=insert_sql,\n                warehouse_id=self.warehouse_id,\n                wait_timeout=\"30s\",\n                parameters=params,\n            )\n            if response.status.state.value == \"SUCCEEDED\":\n                logger.info(\n                    f\"Successfully inserted {num_items} items into Delta table {self.fully_qualified_table_name}\"\n                )\n                return\n            else:\n                logger.error(f\"Failed to insert items: {response.status.error}\")\n                raise Exception(f\"Insert operation failed: {response.status.error}\")\n        except Exception as e:\n            logger.error(f\"Insert operation failed: {e}\")\n            raise\n\n    def search(self, query: str, vectors: list, top_k: int = 5, filters: dict = None) -> List[MemoryResult]:\n        \"\"\"\n        Search for similar vectors or text using the Databricks Vector Search index.\n\n        Args:\n            query (str): Search query text (for text-based search).\n            vectors (list): Query vector (for vector-based search).\n            top_k (int): Maximum number of results.\n            filters (dict): Filters to apply.\n\n        Returns:\n            List of MemoryResult objects.\n        \"\"\"\n        try:","sourceCodeStart":440,"sourceCodeEnd":476,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0/vector_stores/databricks.py#L440-L476","documentation":"Generic Exception raised in Databricks insert when the SQL statement executed against the SQL warehouse does not reach state SUCCEEDED; response.status.error carries the warehouse's error text (syntax, type mismatch, constraint, permission). The except block logs and re-raises, so the original statement execution failures surface wrapped with this message.","triggerScenarios":"Calling insert()/add with rows whose values fail server-side validation: dimension mismatch between the vector column and payload, a truncated/malformed embedding, string values containing unescaped quotes breaking the generated SQL, or the warehouse being terminated mid-statement (wait_timeout='30s' exceeded).","commonSituations":"Switching embedding models so vector length no longer matches the Delta table schema; payload metadata with special characters; warehouse auto-stop terminating during bulk inserts; insufficient ACLs on the destination table.","solutions":["Read response.status.error in the exception message: it names the actual server-side cause — fix that first (schema, permissions, or data).","Recreate/repair the table/index if the embedding dimension changed so inserts match the declared schema.","Ensure the SQL warehouse is running and the 30s wait_timeout suits your batch size; split large inserts into smaller batches.","Catch the exception per-batch and retry only failed batches instead of failing the whole add() call."],"exampleFix":"# before\ntry:\n    store.insert(vectors=[v1, v2, ...], payloads=[p1, p2, ...])\nexcept Exception as e:\n    raise  # whole batch lost, cause hidden\n\n# after\nfor chunk in chunks(items, 100):\n    try:\n        store.insert(vectors=[c.vector for c in chunk], payloads=[c.payload for c in chunk])\n    except Exception as e:\n        logger.error(\"databricks insert failed for chunk: %s\", e)\n        raise","handlingStrategy":"retry","validationCode":"def validate_rows_for_insert(rows, expected_dim: int) -> None:\n    for r in rows:\n        v = r.get(\"vector\")\n        if not v or len(v) != expected_dim:\n            raise ValueError(f\"vector length {len(v) if v else 0} != table dimension {expected_dim}\")\n\nvalidate_rows_for_insert(rows, store.embedding_dimension)","typeGuard":null,"tryCatchPattern":"import time\n\nfor attempt in range(3):\n    try:\n        store.insert(vectors=vectors_chunk, payloads=payloads_chunk)\n        break\n    except Exception as e:\n        msg = str(e)\n        if \"Insert operation failed\" in msg and attempt < 2:\n            time.sleep(2 ** attempt)  # transient warehouse issue; retry chunk\n            continue\n        raise","preventionTips":["Chunk inserts and retry only the failing chunk with backoff for transient warehouse states.","Check embedding dimensions match the table schema before every insert batch.","Keep the SQL warehouse warm (disable auto-stop) during bulk loads and monitor response.status.error text."],"tags":["databricks","sql","insert","runtime"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}