{"record":{"id":"5be09bc7d2c87e8b","repo":"apache/beam","slug":"database-config-must-be-vectordatabasewriteconfig-got-type","errorCode":null,"errorMessage":"database_config must be VectorDatabaseWriteConfig, got {type(database_config)}","messagePattern":"database_config must be VectorDatabaseWriteConfig, got (.+?)","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/ml/rag/ingestion/base.py","lineNumber":95,"sourceCode":"    ...     items = p | beam.Create([...])  # PCollection[EmbeddableItem]\n    ...     items | VectorDatabaseWriteTransform(config)\n\n  Args:\n      database_config: Configuration for the target vector database.\n          Must be a subclass of VectorDatabaseWriteConfig that implements\n          create_write_transform().\n  \n  Raises:\n      TypeError: If database_config is not a VectorDatabaseWriteConfig instance.\n  \"\"\"\n  def __init__(self, database_config: VectorDatabaseWriteConfig):\n    \"\"\"Initialize transform with database config.\n        \n        Args:\n            database_config: Configuration for target vector database.\n        \"\"\"\n    if not isinstance(database_config, VectorDatabaseWriteConfig):\n      raise TypeError(\n          f\"database_config must be VectorDatabaseWriteConfig, \"\n          f\"got {type(database_config)}\")\n    self.database_config = database_config\n\n  def expand(\n      self, pcoll: beam.PCollection[EmbeddableItem]\n  ) -> beam.PTransform[EmbeddableItem, Any]:\n    \"\"\"Creates and applies the database-specific write transform.\n\n    Args:\n        pcoll: PCollection of EmbeddableItems with embeddings to write to the\n            vector database. Each EmbeddableItem must have:\n            - An embedding\n            - An ID\n            - Metadata used to filter results as specified by database config\n\n    Returns:\n        Result of writing to database (implementation specific).","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/ml/rag/ingestion/base.py#L77-L113","documentation":"VectorDatabaseWriteTransform.expand expects its database_config to be an instance of VectorDatabaseWriteConfig. Passing any other object is rejected immediately in __init__ with a TypeError naming the actual type received.","triggerScenarios":"Constructing VectorDatabaseWriteTransform(database_config=...) with a plain dict, a writer object, or an unrelated config class instead of a VectorDatabaseWriteConfig subclass (e.g., BigQueryVectorWriterConfig).","commonSituations":"Mixing up the read-side and write-side config classes; passing the config's constructor kwargs dict instead of a constructed config; refactor renames leaving an old class in place.","solutions":["Pass an instance of VectorDatabaseWriteConfig or a subclass such as BigQueryVectorWriterConfig","If you have raw kwargs, construct the config first: BigQueryVectorWriterConfig(schema_config=..., write_config={...})","Add an isinstance check at your pipeline-construction call site"],"exampleFix":"// before\nVectorDatabaseWriteTransform(database_config={'table': 't'})\n// after\ncfg = BigQueryVectorWriterConfig(schema_config=sc, write_config={'table': 't'})\nVectorDatabaseWriteTransform(database_config=cfg)","handlingStrategy":"type-guard","validationCode":"from apache_beam.ml.rag.ingestion.base import VectorDatabaseWriteConfig\nassert isinstance(cfg, VectorDatabaseWriteConfig)","typeGuard":"def is_write_config(cfg) -> bool:\n    return isinstance(cfg, VectorDatabaseWriteConfig)","tryCatchPattern":"try:\n    t = VectorDatabaseWriteTransform(database_config=cfg)\nexcept TypeError as e:\n    if 'must be VectorDatabaseWriteConfig' in str(e): cfg = build_config_from_dict(cfg)\n    else: raise","preventionTips":["Always pass constructed config objects, not dicts","Use BigQueryVectorWriterConfig or another concrete subclass","Keep read/write config classes in separate, clearly named modules"],"tags":["python","apache-beam","rag","type-error","vector-db"],"backgroundTag":"type-mismatch","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}