{"record":{"id":"d23e2b8210a7b49c","repo":"apache/beam","slug":"could-not-resolve-to-a-temp-directory-for-import-batch-files","errorCode":null,"errorMessage":"could not resolve to a temp directory for import batch files","messagePattern":"could not resolve to a temp directory for import batch files","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"sdks/go/pkg/beam/io/fhirio/import.go","lineNumber":258,"sourceCode":"\t\t\tDeadLetterLocation: deadLetterDir,\n\t\t\tContentStructure:   contentStructure,\n\t\t},\n\t\tbatchFiles,\n\t)\n\treturn failedResources, failedImportsDeadLetter\n}\n\nfunc tryFallbackToDataflowTempDirOrPanic() string {\n\tbeam.PipelineOptions.LoadOptionsFromFlags(nil)\n\tif f := beam.PipelineOptions.Get(\"temp_location\"); f != \"\" {\n\t\treturn f\n\t}\n\n\t// temp_location is optional, so fallback to staging_location.\n\tif f := beam.PipelineOptions.Get(\"staging_location\"); f != \"\" {\n\t\treturn f\n\t}\n\tpanic(\"could not resolve to a temp directory for import batch files\")\n}\n","sourceCodeStart":240,"sourceCodeEnd":260,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/io/fhirio/import.go#L240-L260","documentation":"fhirio's tryFallbackToDataflowTempDirOrPanic panics when neither temp_location nor staging_location pipeline options can be resolved. The FHIR import connector needs a GCS temp/staging directory to stage batch NDJSON files for the $import operation, and without one it cannot proceed.","triggerScenarios":"Running fhirio.Import on Dataflow without setting the temp_location pipeline option, and with staging_location also unset (or empty strings in the pipeline options).","commonSituations":"Submitting a Dataflow job where --temp-location was forgotten; running with a runner that doesn't populate these options automatically; a typo like --temp_location vs --tempLocation in custom submission tooling.","solutions":["Set the Dataflow pipeline option --temp_location=gs://your-bucket/temp when launching the pipeline.","If temp_location is intentionally absent, set --staging_location=gs://your-bucket/staging as the fallback.","Verify the option actually reaches the worker (check beam.PipelineOptions.Get(\"temp_location\") semantics and your submission flags).","Pre-check in main: fail fast with a clear message if both options are empty before building the pipeline."],"exampleFix":"// before\nbeam.Run(ctx, proj, \"dataflow\", p) // no temp_location\n\n// after\n// submit with: --temp_location=gs://my-bucket/temp\nbeam.Run(ctx, proj, \"dataflow\", p)","handlingStrategy":"validation","validationCode":"if beam.PipelineOptions.Get(\"temp_location\") == \"\" && beam.PipelineOptions.Get(\"staging_location\") == \"\" {\n    return errors.New(\"fhirio.Import requires --temp_location or --staging_location pipeline option\")\n}","typeGuard":null,"tryCatchPattern":"defer func() {\n    if r := recover(); r != nil {\n        if strings.Contains(fmt.Sprint(r), \"temp directory\") {\n            log.Fatalf(\"set --temp_location (Dataflow) before using fhirio.Import: %v\", r)\n        }\n        panic(r)\n    }\n}()","preventionTips":["Always pass --temp_location=gs://bucket/path when launching Dataflow jobs using fhirio.","Fail fast in main() when required pipeline options are missing.","Ensure the GCS bucket exists and the service account can write to it."],"tags":["go","fhir","gcs","dataflow","config"],"backgroundTag":"missing-required-config-field","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"}