{"record":{"id":"b5e0056df77adf07","repo":"cocoindex-io/cocoindex","slug":"invalid-bigquery-kind-name-r","errorCode":null,"errorMessage":"Invalid BigQuery {kind}: {name!r}","messagePattern":"Invalid BigQuery (.+?): (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"python/cocoindex/connectors/bigquery/_target.py","lineNumber":243,"sourceCode":"                annotation.encoder,\n                annotation.use_parse_json,\n            )\n\n    base_type = type_info.base_type\n    if base_type in _LEAF_TYPE_MAPPINGS:\n        return _LEAF_TYPE_MAPPINGS[base_type]\n\n    if isinstance(\n        type_info.variant, (SequenceType, MappingType, RecordType, UnionType, AnyType)\n    ):\n        return _JSON_MAPPING\n\n    return _JSON_MAPPING\n\n\ndef _validate_identifier(name: str, kind: str = \"identifier\") -> None:\n    if not isinstance(name, str) or not _IDENTIFIER_RE.match(name):\n        raise ValueError(f\"Invalid BigQuery {kind}: {name!r}\")\n\n\ndef _validate_project_id(project: str) -> None:\n    if not isinstance(project, str) or not _PROJECT_RE.match(project):\n        raise ValueError(f\"Invalid BigQuery project: {project!r}\")\n\n\ndef _quote_path(parts: Sequence[str]) -> str:\n    return f\"`{'.'.join(parts)}`\"\n\n\ndef _qualified_table_name(project: str | None, dataset: str, table_name: str) -> str:\n    parts = []\n    if project is not None:\n        _validate_project_id(project)\n        parts.append(project)\n    _validate_identifier(dataset)\n    _validate_identifier(table_name)","sourceCodeStart":225,"sourceCodeEnd":261,"githubUrl":"https://github.com/cocoindex-io/cocoindex/blob/e84aa99b3292c5270a4b313b2a7137ad9ce8ab3b/python/cocoindex/connectors/bigquery/_target.py#L225-L261","documentation":"_validate_identifier checks that BigQuery dataset and table identifiers are strings matching _IDENTIFIER_RE (BigQuery's legal identifier charset). Invalid characters, backticks, dots inside an identifier, or non-string values raise this ValueError with the offending name and kind.","triggerScenarios":"Calling table_target(client, 'proj.dataset.table', ...) with a dataset/table containing illegal characters (spaces, dashes, dots, backticks) or a non-str (None, int) — via any of the callers _qualified_table_name, _qualified_dataset_name, or table_target.","commonSituations":"Interpolating env vars or user input into table names; using hyphenated names (dashes are illegal in BigQuery identifiers); passing parts that still contain dots from a prior split mistake.","solutions":["Use only letters, numbers, and underscores, starting with a letter or underscore, for dataset/table names.","Replace hyphens with underscores: 'my-dataset' -> 'my_dataset'.","Sanitize/validate dynamically built names before calling table_target (re.match your own allowlist).","Ensure the full qualified name is split into project/dataset/table before validation; don't pass 'proj.ds.tbl' as the dataset part."],"exampleFix":"// before\ntarget = table_target(client, \"my-proj.my-dataset.my table\", Row, primary_key=[\"id\"])\n\n// after\ntarget = table_target(client, \"my_proj.my_dataset.my_table\", Row, primary_key=[\"id\"])","handlingStrategy":"validation","validationCode":"import re\nIDENT = re.compile(r\"[A-Za-z_][A-Za-z0-9_]*\")\nassert IDENT.fullmatch(dataset) and IDENT.fullmatch(table), \"invalid BigQuery identifier\"","typeGuard":"def valid_bq_identifier(name: object) -> bool:\n    import re\n    return isinstance(name, str) and bool(re.fullmatch(r\"[A-Za-z_][A-Za-z0-9_]*\", name))","tryCatchPattern":"try:\n    target = table_target(client, f\"{project}.{dataset}.{table}\", Row, primary_key=pk)\nexcept ValueError as e:\n    logger.error(\"invalid identifier: %s\", e)\n    raise","preventionTips":["Avoid hyphens, spaces, and dots inside dataset/table names.","Sanitize user/env-derived name fragments before composing table names.","Split fully-qualified names into parts before passing them around."],"tags":["python","bigquery","identifier","validation"],"backgroundTag":"invalid-identifier-format","analyzedSha":"e84aa99b3292c5270a4b313b2a7137ad9ce8ab3b","analyzedAt":"2026-09-08T15:59:19.997Z","contentChangedAt":"2026-09-08T15:59:19.997Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}