{"record":{"id":"0118ac878428e23e","repo":"cocoindex-io/cocoindex","slug":"invalid-bigquery-project-project-r","errorCode":null,"errorMessage":"Invalid BigQuery project: {project!r}","messagePattern":"Invalid BigQuery project: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"python/cocoindex/connectors/bigquery/_target.py","lineNumber":248,"sourceCode":"    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)\n    parts.extend([dataset, table_name])\n    return _quote_path(parts)\n\n\ndef _qualified_dataset_name(project: str | None, dataset: str) -> str:","sourceCodeStart":230,"sourceCodeEnd":266,"githubUrl":"https://github.com/cocoindex-io/cocoindex/blob/e84aa99b3292c5270a4b313b2a7137ad9ce8ab3b/python/cocoindex/connectors/bigquery/_target.py#L230-L266","documentation":"_validate_project_id checks that the BigQuery project ID is a string matching _PROJECT_RE. Project IDs differ from other identifiers (they may contain hyphens), but must still be well-formed; an invalid or non-string project raises this ValueError.","triggerScenarios":"Calling table_target or the qualified-name helpers with a project ID containing illegal characters (spaces, underscores where disallowed by the regex, empty string) or a non-string value like None or an int.","commonSituations":"Unset environment variable yielding None or '' for the project; pasting a resource name like 'projects/my-proj' instead of the bare project ID; typo'd project slug.","solutions":["Pass the bare Google Cloud project ID, e.g. 'my-proj-123456', not 'projects/my-proj-123456'.","Check the env/config source: ensure the variable holding the project is set and non-empty.","Strip whitespace and any 'projects/' prefix before calling.","Match the regex your version uses: typically lowercase letters, digits, and hyphens, starting with a letter."],"exampleFix":"// before\nproject = os.environ.get(\"GCP_PROJECT\")  # None if unset\ntarget = table_target(client, f\"{project}.ds.tbl\", Row, primary_key=[\"id\"])\n\n// after\nproject = os.environ[\"GCP_PROJECT\"]  # fails fast if unset\ntarget = table_target(client, f\"{project}.ds.tbl\", Row, primary_key=[\"id\"])","handlingStrategy":"validation","validationCode":"import re\nassert re.fullmatch(r\"[a-z][a-z0-9-]{4,28}[a-z0-9]\", project or \"\"), f\"invalid GCP project id: {project!r}\"","typeGuard":"def valid_project_id(project: object) -> bool:\n    import re\n    return isinstance(project, str) and bool(re.fullmatch(r\"[a-z][a-z0-9-]{4,28}[a-z0-9]\", project))","tryCatchPattern":"try:\n    target = table_target(client, f\"{project}.{dataset}.{table}\", Row, primary_key=pk)\nexcept ValueError as e:\n    logger.error(\"invalid project: %s\", e)\n    raise","preventionTips":["Read the project from a required env var (os.environ[...]) so unset values fail early.","Strip 'projects/' prefixes and whitespace before use.","Keep GCP project IDs lowercase letters, digits, hyphens."],"tags":["python","bigquery","project-id","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"}