{"record":{"id":"b3c590b7041a7b87","repo":"cloudflare/cloudflared","slug":"errcreatingtemporaryfile","errorCode":"ErrCreatingTemporaryFile","errorMessage":"temporary file creation failed","messagePattern":"temporary file creation failed","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"diagnostic/error.go","lineNumber":27,"sourceCode":"\tErrManagedLogNotFound = errors.New(\"managed log directory not found\")\n\t// Error used when it is not possible to collect logs using the log configuration.\n\tErrLogConfigurationIsInvalid = errors.New(\"provided log configuration is invalid\")\n\t// Error used when parsing the fields of the output of collector.\n\tErrInsufficientLines = errors.New(\"insufficient lines\")\n\t// Error used when parsing the lines of the output of collector.\n\tErrInsuficientFields = errors.New(\"insufficient fields\")\n\t// Error used when given key is not found while parsing KV.\n\tErrKeyNotFound = errors.New(\"key not found\")\n\t// Error used when there is no disk volume information available.\n\tErrNoVolumeFound = errors.New(\"no disk volume information found\")\n\t// Error user when the base url of the diagnostic client is not provided.\n\tErrNoBaseURL = errors.New(\"no base url\")\n\t// Error used when no metrics server is found listening to the known addresses list (check [metrics.GetMetricsKnownAddresses]).\n\tErrMetricsServerNotFound = errors.New(\"metrics server not found\")\n\t// Error used when multiple metrics server are found listening to the known addresses list (check [metrics.GetMetricsKnownAddresses]).\n\tErrMultipleMetricsServerFound = errors.New(\"multiple metrics server found\")\n\t// Error used when a temporary file creation fails within the diagnostic procedure\n\tErrCreatingTemporaryFile = errors.New(\"temporary file creation failed\")\n)\n","sourceCodeStart":9,"sourceCodeEnd":29,"githubUrl":"https://github.com/cloudflare/cloudflared/blob/2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f/diagnostic/error.go#L9-L29","documentation":"ErrCreatingTemporaryFile is returned by diagnostic procedures (collectLogs, rawNetworkInformationWriter, jsonNetworkInformationWriter, createTaskReport) when os.Create on a file in os.TempDir() fails. The diagnostic pipeline writes logs, network dumps, and task reports to temporary files before zipping them; if that creation fails the diagnostic cannot proceed. The original os error is discarded, so only the sentinel is visible.","triggerScenarios":"os.Create(filepath.Join(os.TempDir(), ...)) failing at diagnostic/diagnostic.go:140 (output log), diagnostic/diagnostic.go:242 (raw network dump), and in the JSON network writer and createTaskReport paths — e.g. unwritable TMPDIR, full disk, or the path existing as a directory.","commonSituations":"Read-only or full /tmp, TMPDIR pointing to a non-existent or permission-restricted directory, running under a sandboxed service account with no write access to the temp directory, or a stale file/dir collision at the target name.","solutions":["Check that os.TempDir() (or $TMPDIR) exists and is writable by the user running cloudflared.","Free disk space on the volume holding the temp directory.","Remove any conflicting file/directory at the temp path the diagnostic writes to.","Set TMPDIR to a writable location before launching the diagnostic."],"exampleFix":"// before\noutputLogHandle, err := os.Create(filepath.Join(os.TempDir(), logFilename))\nif err != nil {\n\treturn \"\", ErrCreatingTemporaryFile\n}\n// after\noutputLogHandle, err := os.Create(filepath.Join(os.TempDir(), logFilename))\nif err != nil {\n\treturn \"\", fmt.Errorf(\"%w: %v\", ErrCreatingTemporaryFile, err)\n}","handlingStrategy":"validation","validationCode":"tmp := os.TempDir()\nif fi, err := os.Stat(tmp); err != nil || !fi.IsDir() {\n\treturn errors.New(\"temp directory unavailable\")\n}\nif f, err := os.CreateTemp(tmp, \"cfd-diag-*\"); err != nil {\n\treturn fmt.Errorf(\"temp dir not writable: %w\", err)\n} else {\n\tf.Close()\n\tos.Remove(f.Name())\n}","typeGuard":null,"tryCatchPattern":"out, err := diagnostic.RunDiagnostic(log, options)\nif errors.Is(err, diagnostic.ErrCreatingTemporaryFile) {\n\treturn fmt.Errorf(\"diagnostic failed: cannot write to %s: %w\", os.TempDir(), err)\n}","preventionTips":["Ensure TMPDIR points to an existing, writable directory for the process user.","Monitor disk space on the temp volume; dumps can be large.","Run cloudflared diagnostics as a user with write access to the system temp directory.","Wrap sentinel returns with the underlying os error to ease future debugging."],"tags":["filesystem","temp-file","diagnostic"],"backgroundTag":"file-write-failed","analyzedSha":"2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f","analyzedAt":"2026-09-06T04:14:33.757Z","contentChangedAt":"2026-09-06T04:14:33.757Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}