apache/beam · error · TypeError
Unexpected keyword arguments: {', '.join(kwargs)}
Error message
Unexpected keyword arguments: {', '.join(kwargs)} What it means
The BigQuery RAG ingestion SchemaConfig __init__ accepts known keyword arguments plus the deprecated chunk_to_dict_fn alias; any remaining unexpected kwargs raise a TypeError listing them. This guards against silently ignored misnamed options.
Source
Thrown at sdks/python/apache_beam/ml/rag/ingestion/bigquery.py:76
... {'name': 'source_url', 'type': 'STRING'}
... ]
... },
... embeddable_to_dict_fn=lambda item: {
... 'id': item.id,
... 'embedding': item.embedding.dense_embedding,
... 'source_url': item.metadata.get('url')
... }
... )
"""
self.schema = schema
if 'chunk_to_dict_fn' in kwargs:
warnings.warn(
"chunk_to_dict_fn is deprecated, use embeddable_to_dict_fn",
DeprecationWarning,
stacklevel=2)
embeddable_to_dict_fn = kwargs.pop('chunk_to_dict_fn')
if kwargs:
raise TypeError(f"Unexpected keyword arguments: {', '.join(kwargs)}")
if embeddable_to_dict_fn is None:
raise TypeError("SchemaConfig requires embeddable_to_dict_fn")
self.embeddable_to_dict_fn = embeddable_to_dict_fn
class BigQueryVectorWriterConfig(VectorDatabaseWriteConfig):
def __init__(
self,
write_config: dict[str, Any],
*, # Force keyword arguments
schema_config: Optional[SchemaConfig] = None):
"""Configuration for writing vectors to BigQuery using managed transforms.
Supports both default schema (id, embedding, content, metadata columns) and
custom schemas through SchemaConfig.
Example with default schema:
>>> config = BigQueryVectorWriterConfig(View on GitHub (pinned to 12126d8942)
Solutions
- Remove or correct the unexpected keyword arguments listed in the message
- Move write-related options (table etc.) into BigQueryVectorWriterConfig/write_config
- Replace legacy chunk_to_dict_fn with embeddable_to_dict_fn (the only accepted alias)
Example fix
// before SchemaConfig(embeddable_to_dct_fn=fn) # typo -> unexpected kwarg // after SchemaConfig(embeddable_to_dict_fn=fn)
Defensive patterns
Strategy: validation
Validate before calling
ALLOWED = {'embeddable_to_dict_fn', 'chunk_to_dict_fn'}
unknown = set(kwargs) - ALLOWED
assert not unknown, f'unexpected SchemaConfig kwargs: {unknown}' Type guard
def valid_schema_config_kwargs(kwargs: dict) -> bool:
return not (set(kwargs) - {'embeddable_to_dict_fn', 'chunk_to_dict_fn'}) Try / catch
try:
sc = SchemaConfig(**opts)
except TypeError as e:
if str(e).startswith('Unexpected keyword arguments'): retry_with_cleaned_kwargs(opts)
else: raise Prevention
- Check the SchemaConfig signature before passing **opts
- Put write options in BigQueryVectorWriterConfig, not SchemaConfig
- Migrate chunk_to_dict_fn to embeddable_to_dict_fn
When it happens
Trigger: Calling SchemaConfig(...) with keyword arguments other than embeddable_to_dict_fn / metadata_fn-style accepted params, or the legacy chunk_to_dict_fn.
Common situations: Typos like embeddable_to_dict_func; passing writer options (table, project) into SchemaConfig instead of BigQueryVectorWriterConfig; old code still passing removed parameters.
Understand the failure class
Background: "must be a positive integer", "cannot be empty", "invalid argument": how invalid-argument errors work across open-source libraries — this error's family across 33 libraries.
Related errors
- %s: gcs_location must be of type string or ValueProvider; go
- %s: table must be of type string; got a callable instead
- Table schema must be of the type bigquery.TableSchema
- Unexpected schema argument: %s.
- Item {item.id} missing embedding
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/92ec4be791069cb7.
Report an issue: GitHub.