{"record":{"id":"772b33f8e7a6c618","repo":"apache/beam","slug":"error-constructing-default-value-for-gcptemplocation","errorCode":null,"errorMessage":"Error constructing default value for gcpTempLocation: tempLocation is not a valid GCS path, ${tempLocation}. ","messagePattern":"Error constructing default value for gcpTempLocation: tempLocation is not a valid GCS path, (.+?)\\. ","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/extensions/google-cloud-platform-core/src/main/java/org/apache/beam/sdk/extensions/gcp/options/GcpOptions.java","lineNumber":389,"sourceCode":"    static final String DEFAULT_REGION = \"us-central1\";\n    private static final Logger LOG = LoggerFactory.getLogger(GcpTempLocationFactory.class);\n\n    @Override\n    public @Nullable String create(PipelineOptions options) {\n      String tempLocation = options.getTempLocation();\n      if (isNullOrEmpty(tempLocation)) {\n        tempLocation =\n            tryCreateDefaultBucket(\n                options,\n                newCloudResourceManagerClient(options.as(CloudResourceManagerOptions.class))\n                    .build());\n        options.setTempLocation(tempLocation);\n      } else {\n        try {\n          PathValidator validator = options.as(GcsOptions.class).getPathValidator();\n          validator.validateOutputFilePrefixSupported(tempLocation);\n        } catch (Exception e) {\n          throw new IllegalArgumentException(\n              String.format(\n                  \"Error constructing default value for gcpTempLocation: tempLocation is not\"\n                      + \" a valid GCS path, %s. \",\n                  tempLocation),\n              e);\n        }\n      }\n\n      if (isSoftDeletePolicyEnabled(options, tempLocation)) {\n        LOG.warn(\n            \"The bucket of gcpTempLocation {} has soft delete policy enabled.\"\n                + \" Dataflow jobs use Cloud Storage to store temporary files during pipeline\"\n                + \" execution. To avoid being billed for unnecessary storage costs, turn off the soft\"\n                + \" delete feature on buckets that your Dataflow jobs use for temporary storage.\"\n                + \" For more information, see\"\n                + \" https://cloud.google.com/storage/docs/use-soft-delete#remove-soft-delete-policy.\",\n            tempLocation);\n      }","sourceCodeStart":371,"sourceCodeEnd":407,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/extensions/google-cloud-platform-core/src/main/java/org/apache/beam/sdk/extensions/gcp/options/GcpOptions.java#L371-L407","documentation":"GcpOptions.GcsTempLocationFactory validates the derived tempLocation with the GCS PathValidator; if validation throws, it is rethrown as IllegalArgumentException saying tempLocation is not a valid GCS path. It means the resolved default temp location is not a usable gs:// output prefix.","triggerScenarios":"PipelineOptions validation when gcpTempLocation is unset and tempLocation defaults from project/bucket inference, then validator.validateOutputFilePrefixSupported(tempLocation) throws because the string is not gs:// prefixed, the bucket is missing, or is not writable.","commonSituations":"Setting tempLocation to a local directory (e.g. /tmp) instead of a GCS path when running on Dataflow; typo in bucket name; bucket in a different project; no storage.objects.create permission.","solutions":["Explicitly set --gcpTempLocation (or --tempLocation) to a valid gs://bucket/path prefix","Create the bucket and confirm it is in the same project as --project","Grant the identity storage.objects.create/list on the bucket","Check that no conflicting --tempLocation default factory is producing a non-GCS path"],"exampleFix":"// before\n--tempLocation=/tmp/beam-temp\n// after\n--tempLocation=gs://my-bucket/temp","handlingStrategy":"validation","validationCode":"String tmp = options.as(GcpOptions.class).getGcpTempLocation();\nif (tmp == null) tmp = options.getTempLocation();\nif (tmp == null || !tmp.startsWith(\"gs://\"))\n  throw new IllegalArgumentException(\"tempLocation must be a gs:// path for GCP runs: \" + tmp);","typeGuard":null,"tryCatchPattern":"try {\n  options.as(GcpOptions.class).getGcpTempLocation();\n} catch (IllegalArgumentException e) {\n  options.as(GcpOptions.class).setGcpTempLocation(\"gs://my-bucket/temp\");\n}","preventionTips":["Always set --gcpTempLocation explicitly for Dataflow runs","Never point tempLocation at a local filesystem path on GCP runners","Pre-create the bucket and confirm write access","Keep tempLocation and project in the same GCP project"],"tags":["gcp","gcs","configuration","validation","java"],"backgroundTag":"invalid-argument-value","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"}