{"record":{"id":"6cb63fba0a9d074c","repo":"apache/beam","slug":"unable-to-get-spanner-instanceconfigid-for","errorCode":null,"errorMessage":"unable to get Spanner instanceConfigId for {}","messagePattern":"unable to get Spanner instanceConfigId for (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/spanner/SpannerAccessor.java","lineNumber":354,"sourceCode":"    String databaseId = spannerConfig.getDatabaseId().get();\n    DatabaseClient databaseClient =\n        spanner.getDatabaseClient(DatabaseId.of(options.getProjectId(), instanceId, databaseId));\n    BatchClient batchClient =\n        spanner.getBatchClient(DatabaseId.of(options.getProjectId(), instanceId, databaseId));\n    DatabaseAdminClient databaseAdminClient = spanner.getDatabaseAdminClient();\n    String instanceConfigId = \"unknown\";\n    try {\n      instanceConfigId =\n          spanner\n              .getInstanceAdminClient()\n              .getInstance(instanceId)\n              .getInstanceConfigId()\n              .getInstanceConfig();\n    } catch (Exception e) {\n      // fetch instanceConfigId is fail-free.\n      // Do not emit warning when serviceFactory is overridden (e.g. in tests).\n      if (spannerConfig.getServiceFactory() == null) {\n        LOG.warn(\"unable to get Spanner instanceConfigId for {}\", instanceId, e);\n      }\n    }\n\n    return new SpannerAccessor(\n        spanner, databaseClient, databaseAdminClient, batchClient, spannerConfig, instanceConfigId);\n  }\n\n  public DatabaseClient getDatabaseClient() {\n    return databaseClient;\n  }\n\n  public BatchClient getBatchClient() {\n    return batchClient;\n  }\n\n  public DatabaseAdminClient getDatabaseAdminClient() {\n    return databaseAdminClient;\n  }","sourceCodeStart":336,"sourceCodeEnd":372,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/spanner/SpannerAccessor.java#L336-L372","documentation":"While creating the Spanner client, SpannerAccessor tries to fetch the instance's instanceConfigId for informational/validation purposes. Any exception during that lookup is swallowed and only logged as a warning (and suppressed entirely when a custom ServiceFactory is set, e.g. in tests). The SpannerAccessor is still returned; instanceConfigId may be null, which typically only matters for features that inspect the instance config (e.g. multi-region handling).","triggerScenarios":"spannerConfig.getServiceFactory() == null and the call spanner.getInstanceAdminClient().getInstance(instanceId).getInstanceConfigId().getInstanceConfig() throws — most commonly InstanceNotFoundException when the instanceId does not exist, or permission/API errors fetching the instance config.","commonSituations":"Typo in the Spanner instance ID in SpannerIO.read/write config; the Cloud Spanner admin API is disabled or blocked by network/VPC config; the service account lacks spanner.instances.get permission.","solutions":["Verify the instanceId in SpannerConfig matches an existing Cloud Spanner instance (check in the GCP console or via gcloud spanner instances list).","Grant the service account the Cloud Spanner Viewer (or Admin) role so it can read instance metadata.","Check that the Spanner Admin API is enabled and reachable from your environment.","Inspect the exception attached to this warning for the root cause."],"exampleFix":"// before\nSpannerConfig config = SpannerConfig.create()\n    .withInstanceId(\"my-instnace\") // typo\n\n// after\nSpannerConfig config = SpannerConfig.create()\n    .withInstanceId(\"my-instance\")","handlingStrategy":"validation","validationCode":"// Before submitting the pipeline, verify the instance exists and is readable:\ngcloud spanner instances describe my-instance --project=my-project","typeGuard":null,"tryCatchPattern":"// No exception escapes; the warning is swallowed. Detect degraded setup by asserting on the built accessor's config:\nif (spannerConfig.getInstanceId() == null) {\n  throw new IllegalArgumentException(\"Spanner instanceId must be set\");\n}","preventionTips":["Verify instanceId/databaseId/projectId in SpannerConfig against gcloud before running.","Grant the pipeline's service account spanner.instances.get (Cloud Spanner Viewer or higher).","Enable the Cloud Spanner Admin API in the project."],"tags":["java","spanner","gcp","instance-config"],"backgroundTag":"resource-not-found","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}