apache/beam · error · TypeError

database_config must be VectorDatabaseWriteConfig, got {type

Error message

database_config must be VectorDatabaseWriteConfig, got {type(database_config)}

What it means

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.

Source

Thrown at sdks/python/apache_beam/ml/rag/ingestion/base.py:95

    ...     items = p | beam.Create([...])  # PCollection[EmbeddableItem]
    ...     items | VectorDatabaseWriteTransform(config)

  Args:
      database_config: Configuration for the target vector database.
          Must be a subclass of VectorDatabaseWriteConfig that implements
          create_write_transform().
  
  Raises:
      TypeError: If database_config is not a VectorDatabaseWriteConfig instance.
  """
  def __init__(self, database_config: VectorDatabaseWriteConfig):
    """Initialize transform with database config.
        
        Args:
            database_config: Configuration for target vector database.
        """
    if not isinstance(database_config, VectorDatabaseWriteConfig):
      raise TypeError(
          f"database_config must be VectorDatabaseWriteConfig, "
          f"got {type(database_config)}")
    self.database_config = database_config

  def expand(
      self, pcoll: beam.PCollection[EmbeddableItem]
  ) -> beam.PTransform[EmbeddableItem, Any]:
    """Creates and applies the database-specific write transform.

    Args:
        pcoll: PCollection of EmbeddableItems with embeddings to write to the
            vector database. Each EmbeddableItem must have:
            - An embedding
            - An ID
            - Metadata used to filter results as specified by database config

    Returns:
        Result of writing to database (implementation specific).

View on GitHub (pinned to 12126d8942)

Solutions

  1. Pass an instance of VectorDatabaseWriteConfig or a subclass such as BigQueryVectorWriterConfig
  2. If you have raw kwargs, construct the config first: BigQueryVectorWriterConfig(schema_config=..., write_config={...})
  3. Add an isinstance check at your pipeline-construction call site

Example fix

// before
VectorDatabaseWriteTransform(database_config={'table': 't'})
// after
cfg = BigQueryVectorWriterConfig(schema_config=sc, write_config={'table': 't'})
VectorDatabaseWriteTransform(database_config=cfg)
Defensive patterns

Strategy: type-guard

Validate before calling

from apache_beam.ml.rag.ingestion.base import VectorDatabaseWriteConfig
assert isinstance(cfg, VectorDatabaseWriteConfig)

Type guard

def is_write_config(cfg) -> bool:
    return isinstance(cfg, VectorDatabaseWriteConfig)

Try / catch

try:
    t = VectorDatabaseWriteTransform(database_config=cfg)
except TypeError as e:
    if 'must be VectorDatabaseWriteConfig' in str(e): cfg = build_config_from_dict(cfg)
    else: raise

Prevention

When it happens

Trigger: Constructing VectorDatabaseWriteTransform(database_config=...) with a plain dict, a writer object, or an unrelated config class instead of a VectorDatabaseWriteConfig subclass (e.g., BigQueryVectorWriterConfig).

Common situations: 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.

Understand the failure class

Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.

Related errors


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/5be09bc7d2c87e8b. Report an issue: GitHub.