{"record":{"id":"1558c8cf2394a324","repo":"apache/beam","slug":"invalid-staging-location-v","errorCode":null,"errorMessage":"invalid staging location %v","messagePattern":"invalid staging location (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/runners/dataflow/dataflowlib/stage.go","lineNumber":58,"sourceCode":"\tfd, err := os.Open(filename)\n\tif err != nil {\n\t\treturn \"\", errors.Wrapf(err, \"failed to open file %s\", filename)\n\t}\n\tdefer fd.Close()\n\n\tsha256W := sha256.New()\n\ttee := io.TeeReader(fd, sha256W)\n\tif err := upload(ctx, project, url, tee); err != nil {\n\t\treturn \"\", err\n\t}\n\thash := hex.EncodeToString(sha256W.Sum(nil))\n\treturn hash, nil\n}\n\nfunc upload(ctx context.Context, project, object string, r io.Reader) error {\n\tbucket, obj, err := gcsx.ParseObject(object)\n\tif err != nil {\n\t\treturn errors.Wrapf(err, \"invalid staging location %v\", object)\n\t}\n\tclient, err := gcsx.NewClient(ctx, storage.ScopeReadWrite)\n\tif err != nil {\n\t\treturn err\n\t}\n\t_, err = gcsx.Upload(ctx, client, project, bucket, obj, r)\n\treturn err\n}\n\n// ResolveXLangArtifacts resolves cross-language artifacts with a given GCS\n// URL as a destination, and then stages all local artifacts to that URL. This\n// function returns a list of staged artifact URLs.\nfunc ResolveXLangArtifacts(ctx context.Context, edges []*graph.MultiEdge, project, url string) ([]string, error) {\n\tcfg := xlangx.ResolveConfig{\n\t\tSdkPath: url,\n\t\tJoinFn: func(url, name string) string {\n\t\t\treturn gcsx.Join(url, \"/\", name)\n\t\t},","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/runners/dataflow/dataflowlib/stage.go#L40-L76","documentation":"upload validates the staging destination with gcsx.ParseObject before creating a storage client. ParseObject requires a URL that parses and has the 'gs' scheme plus a non-empty bucket (host). Any staging location that is not a well-formed gs://bucket/path string is rejected with this wrapped error.","triggerScenarios":"StageModel or stageFile calls upload with an object string whose scheme is not 'gs' (e.g. a local path like ./staging, an https:// URL, or 'gs://' with no bucket).","commonSituations":"The --staging_location flag was set to an S3/https/local path or omitted/defaulted incorrectly; a trailing typo like 'gcs://bucket/obj'; missing bucket after 'gs://'; case sensitivity in 'gs'.","solutions":["Set --staging_location to a full valid GCS path: gs://<bucket>/<prefix>, e.g. gs://my-bucket/staging.","Ensure the location starts with the exact 'gs://' scheme and names an existing bucket you can write to.","Verify with gcsx.ParseObject locally before submitting: bucket, obj, err := gcsx.ParseObject(location).","If using temp_location too, confirm it is also a gs:// URL, not a local dir."],"exampleFix":"// before\n--staging_location=./build/staging\n// after\n--staging_location=gs://my-project-bucket/staging","handlingStrategy":"validation","validationCode":"bucket, obj, err := gcsx.ParseObject(stagingLocation)\nif err != nil {\n    return fmt.Errorf(\"--staging_location must be gs://bucket/path, got %q: %w\", stagingLocation, err)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Standardize staging locations as gs://bucket/prefix constants in job configs.","Never pass local paths or non-gs URLs as staging locations.","Validate flags with ParseObject in a pre-submit check."],"tags":["go","gcp","dataflow","gcs","url-validation"],"backgroundTag":"invalid-url-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"}