{"record":{"id":"f1218838274acb14","repo":"apache/beam","slug":"schemaconfig-requires-embeddable-to-dict-fn","errorCode":null,"errorMessage":"SchemaConfig requires embeddable_to_dict_fn","messagePattern":"SchemaConfig requires embeddable_to_dict_fn","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/ml/rag/ingestion/bigquery.py","lineNumber":78,"sourceCode":"      ...   },\n      ...   embeddable_to_dict_fn=lambda item: {\n      ...       'id': item.id,\n      ...       'embedding': item.embedding.dense_embedding,\n      ...       'source_url': item.metadata.get('url')\n      ...   }\n      ... )\n    \"\"\"\n    self.schema = schema\n    if 'chunk_to_dict_fn' in kwargs:\n      warnings.warn(\n          \"chunk_to_dict_fn is deprecated, use embeddable_to_dict_fn\",\n          DeprecationWarning,\n          stacklevel=2)\n      embeddable_to_dict_fn = kwargs.pop('chunk_to_dict_fn')\n    if kwargs:\n      raise TypeError(f\"Unexpected keyword arguments: {', '.join(kwargs)}\")\n    if embeddable_to_dict_fn is None:\n      raise TypeError(\"SchemaConfig requires embeddable_to_dict_fn\")\n    self.embeddable_to_dict_fn = embeddable_to_dict_fn\n\n\nclass BigQueryVectorWriterConfig(VectorDatabaseWriteConfig):\n  def __init__(\n      self,\n      write_config: dict[str, Any],\n      *,  # Force keyword arguments\n      schema_config: Optional[SchemaConfig] = None):\n    \"\"\"Configuration for writing vectors to BigQuery using managed transforms.\n    \n    Supports both default schema (id, embedding, content, metadata columns) and\n    custom schemas through SchemaConfig.\n\n    Example with default schema:\n      >>> config = BigQueryVectorWriterConfig(\n      ...     write_config={'table': 'project.dataset.embeddings'})\n","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/ml/rag/ingestion/bigquery.py#L60-L96","documentation":"SchemaConfig requires a function that converts an EmbeddableItem into a dict row matching the BigQuery schema. If embeddable_to_dict_fn is None (and the deprecated chunk_to_dict_fn was not supplied), __init__ raises this TypeError because the writer would have no way to map items to rows.","triggerScenarios":"Constructing SchemaConfig() with no embeddable_to_dict_fn argument, or passing embeddable_to_dict_fn=None explicitly.","commonSituations":"Omitting the function in config builders; conditional code paths that default the fn to None; migrating from chunk_to_dict_fn but misspelling the new name so both remain None.","solutions":["Pass a callable embeddable_to_dict_fn(item: EmbeddableItem) -> dict to SchemaConfig","Or pass the deprecated chunk_to_dict_fn (emits a DeprecationWarning) if migrating gradually","If rows match the default shape, use the module-provided _default_embeddable_to_dict_fn behavior as a template"],"exampleFix":"// before\nsc = SchemaConfig()\n// after\nsc = SchemaConfig(embeddable_to_dict_fn=lambda item: {\n    'id': item.id, 'embedding': item.embedding.dense_embedding,\n    'content': item.content_string, 'metadata': []})","handlingStrategy":"validation","validationCode":"assert callable(getattr(sc_kwargs.get('embeddable_to_dict_fn'), '__call__', None)), 'embeddable_to_dict_fn required'","typeGuard":"def has_dict_fn(kwargs: dict) -> bool:\n    fn = kwargs.get('embeddable_to_dict_fn') or kwargs.get('chunk_to_dict_fn')\n    return callable(fn)","tryCatchPattern":"try:\n    sc = SchemaConfig(**kwargs)\nexcept TypeError as e:\n    if 'requires embeddable_to_dict_fn' in str(e): sc = SchemaConfig(embeddable_to_dict_fn=default_fn)\n    else: raise","preventionTips":["Always pass embeddable_to_dict_fn when building SchemaConfig","Default to the module's default converter when row shape matches","Add config-construction unit tests"],"tags":["python","apache-beam","bigquery","rag","validation"],"backgroundTag":"missing-required-argument","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"}