{"record":{"id":"efcb6aec35a30e00","repo":"apache/beam","slug":"table-reference-is-not-in-projects-project-id-datasets","errorCode":null,"errorMessage":"Table reference is not in projects/[project_id]/datasets/[dataset_id]/tables/[table_id] format: \" + tableUrn","messagePattern":"Table reference is not in projects/\\[project_id\\]/datasets/\\[dataset_id\\]/tables/\\[table_id\\] format: \" \\+ tableUrn","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryHelpers.java","lineNumber":569,"sourceCode":"    return ref.setDatasetId(dataset).setTableId(table);\n  }\n\n  private static IllegalArgumentException invalidTableSpec(String tableSpec) {\n    return new IllegalArgumentException(\n        String.format(\n            \"Table specification [%s] is not in one of the expected formats (\"\n                + \" [project_id]:[dataset_id].[table_id],\"\n                + \" [project_id].[dataset_id].[table_id],\"\n                + \" [dataset_id].[table_id],\"\n                + \" [project_id]:[catalog_id].[namespace_id].[table_id],\"\n                + \" [project_id].[catalog_id].[namespace_id].[table_id])\",\n            tableSpec));\n  }\n\n  public static TableReference parseTableUrn(String tableUrn) {\n    Matcher match = BigQueryIO.TABLE_URN_SPEC.matcher(tableUrn);\n    if (!match.matches()) {\n      throw new IllegalArgumentException(\n          \"Table reference is not in projects/[project_id]/datasets/[dataset_id]/tables/[table_id] \"\n              + \"format: \"\n              + tableUrn);\n    }\n\n    return new TableReference()\n        .setProjectId(checkStateNotNull(match.group(\"PROJECT\")))\n        .setDatasetId(checkStateNotNull(match.group(\"DATASET\")))\n        .setTableId(checkStateNotNull(match.group(\"TABLE\")));\n  }\n\n  /** Strip off any partition decorator information from a tablespec. */\n  public static String stripPartitionDecorator(String tableSpec) {\n    int index = tableSpec.lastIndexOf('$');\n    return (index == -1) ? tableSpec : tableSpec.substring(0, index);\n  }\n\n  static String jobToPrettyString(@Nullable Job job) throws IOException {","sourceCodeStart":551,"sourceCodeEnd":587,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryHelpers.java#L551-L587","documentation":"parseTableUrn() validates that a table resource string matches the canonical BigQuery URN format projects/[project_id]/datasets/[dataset_id]/tables/[table_id]. If the regex TABLE_URN_SPEC doesn't match, the string cannot be decomposed into project/dataset/table, so it throws IllegalArgumentException.","triggerScenarios":"Calling BigQueryHelpers.parseTableUrn() with a string that isn't a full table URN, e.g. 'my_dataset.my_table', 'project:dataset.table', a tableSpec, or a URL.","commonSituations":"Passing a tableSpec ('project:dataset.table') or legacy notation where a URN is required (e.g. SchemaTransform identifiers, ResourceIds), or copy-pasting a dataset-only reference.","solutions":["Convert the string to the full URN form: projects/<project>/datasets/<dataset>/tables/<table>.","If you have a tableSpec instead, use BigQueryHelpers.parseString/TableReference parsing (parseTableSpec) rather than parseTableUrn.","Log the input string and validate its shape before calling."],"exampleFix":"// before\nTableReference ref = BigQueryHelpers.parseTableUrn(\"my-project:my_dataset.my_table\");\n\n// after\nTableReference ref = BigQueryHelpers.parseTableUrn(\n    \"projects/my-project/datasets/my_dataset/tables/my_table\");","handlingStrategy":"validation","validationCode":"static boolean isValidTableUrn(String urn) {\n  return urn != null && urn.matches(\"projects/[^/]+/datasets/[^/]+/tables/[^/]+\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  TableReference ref = BigQueryHelpers.parseTableUrn(urn);\n} catch (IllegalArgumentException e) {\n  // fall back to parseTableSpec or fix the URN format\n}","preventionTips":["Always build table URNs from TableReference project/dataset/table parts instead of string concatenation.","Distinguish URN format (projects/.../tables/...) from tableSpec format (project:dataset.table).","Validate resource strings with the regex before parsing."],"tags":["java","bigquery","format-validation","illegal-argument"],"backgroundTag":"invalid-argument-format","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"}