{"record":{"id":"4177ba0b1c2c7792","repo":"apache/beam","slug":"tablefieldsqueryconfig-must-provide-table-id-and-where","errorCode":null,"errorMessage":"TableFieldsQueryConfig must provide table_id and where_clause_template","messagePattern":"TableFieldsQueryConfig must provide table_id and where_clause_template","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/transforms/enrichment_handlers/cloudsql.py","lineNumber":64,"sourceCode":"class CustomQueryConfig:\n  \"\"\"Configuration for using a custom query function.\"\"\"\n  query_fn: QueryFn\n\n  def __post_init__(self):\n    if not self.query_fn:\n      raise ValueError(\"CustomQueryConfig must provide a valid query_fn\")\n\n\n@dataclass\nclass TableFieldsQueryConfig:\n  \"\"\"Configuration for using table name, where clause, and field names.\"\"\"\n  table_id: str\n  where_clause_template: str\n  where_clause_fields: list[str]\n\n  def __post_init__(self):\n    if not self.table_id or not self.where_clause_template:\n      raise ValueError(\n          \"TableFieldsQueryConfig must provide table_id and \" +\n          \"where_clause_template\")\n\n    if not self.where_clause_fields:\n      raise ValueError(\n          \"TableFieldsQueryConfig must provide non-empty \" +\n          \"where_clause_fields\")\n\n\n@dataclass\nclass TableFunctionQueryConfig:\n  \"\"\"Configuration for using table name, where clause, and a value function.\"\"\"\n  table_id: str\n  where_clause_template: str\n  where_clause_value_fn: ConditionValueFn\n\n  def __post_init__(self):\n    if not self.table_id or not self.where_clause_template:","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/transforms/enrichment_handlers/cloudsql.py#L46-L82","documentation":"TableFieldsQueryConfig.__post_init__ requires both table_id and where_clause_template; if either is missing or empty a ValueError is raised. Without these, the handler cannot build the parameterized SQL query for Cloud SQL enrichment.","triggerScenarios":"Constructing TableFieldsQueryConfig(table_id='', where_clause_template='WHERE x', ...) or omitting either required dataclass field (None/empty string).","commonSituations":"Filling in fields from environment/config where values end up empty strings; forgetting to template the WHERE clause when switching from CustomQueryConfig.","solutions":["Provide both table_id and a non-empty where_clause_template string","Validate your config source (YAML/env) before constructing the dataclass","Use CustomQueryConfig if you'd rather write the full query yourself"],"exampleFix":"// before\nTableFieldsQueryConfig(table_id='', where_clause_template=None, where_clause_fields=['id'])\n// after\nTableFieldsQueryConfig(table_id='users', where_clause_template='WHERE id = :id', where_clause_fields=['id'])","handlingStrategy":"validation","validationCode":"def make_table_fields(table_id, tmpl, fields):\n    assert table_id, 'table_id required'\n    assert tmpl, 'where_clause_template required'\n    assert fields, 'where_clause_fields required'\n    return TableFieldsQueryConfig(table_id, tmpl, fields)","typeGuard":null,"tryCatchPattern":"try:\n    cfg = TableFieldsQueryConfig(**raw)\nexcept ValueError as e:\n    raise ValueError(f'invalid TableFieldsQueryConfig: {e}') from e","preventionTips":["Validate YAML/env config for empty strings before constructing configs","Keep table_id and template together in a single config source","Add unit tests constructing each config variant"],"tags":["python","apache-beam","cloudsql","dataclass","validation"],"backgroundTag":"empty-required-field","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}