{"record":{"id":"99dda806d8a93e60","repo":"OpenNHP/opennhp","slug":"error-fail-to-generating-temporary-file-path-w","errorCode":null,"errorMessage":"Error: fail to generating temporary file path: %w","messagePattern":"Error: fail to generating temporary file path: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"endpoints/agent/udpagent.go","lineNumber":1353,"sourceCode":"\t\tDoId:                       ztdoId,\n\t\tUserId:                     a.config.UserId,\n\t\tTeePublicKey:               teeEcdh.PublicKeyBase64(),\n\t\tConsumerEphemeralPublicKey: consumerEphemeralEcdh.PublicKeyBase64(),\n\t}\n\tserverPeer := a.GetFirstServerPeer()\n\tresult, dagMsg := a.SendDARMsgToServer(serverPeer, darMsg)\n\tif result {\n\t\ta.trustedByNHPDB.Store(true) // agent has been trusted by NHP DB\n\n\t\t// update smart data policy refresh time\n\t\ta.smartDataPolicyRefreshTime[ztdoId] = time.Now().UnixNano()\n\n\t\tlog.Info(\"[StartConfidentialComputing] Refresh smart data policy for data object which id is %s\", ztdoId)\n\n\t\tif !decrypted {\n\t\t\toutput, err = utils.GenerateTempFilePath(\"plaintext-*\")\n\t\t\tif err != nil {\n\t\t\t\treturn \"\", fmt.Errorf(\"Error: fail to generating temporary file path: %w\", err)\n\t\t\t}\n\n\t\t\tdataPrkWrapping := ztdolib.DataPrivateKeyWrapping{}\n\n\t\t\tif err := json.Unmarshal([]byte(dagMsg.Kao.WrappedDataKey), &dataPrkWrapping); err != nil {\n\t\t\t\tlog.Error(\"failed to unmarshal data private key wrapping: %v\\n\", err)\n\t\t\t\treturn \"\", fmt.Errorf(\"failed to unmarshal data private key wrapping: %v\", err)\n\t\t\t}\n\n\t\t\tproviderPbk, _ := base64.StdEncoding.DecodeString(dataPrkWrapping.ProviderPublicKeyBase64)\n\n\t\t\tif dagMsg.AccessUrl == \"\" {\n\t\t\t\tlog.Error(\"access url is empty, please check with data provider\")\n\t\t\t\treturn \"\", fmt.Errorf(\"access url is empty, please check with data provider\")\n\t\t\t}\n\n\t\t\tvar err error\n\t\t\tztdoPath, err := utils.DownloadFileToTemp(dagMsg.AccessUrl, \"ztdo-\")","sourceCodeStart":1335,"sourceCodeEnd":1371,"githubUrl":"https://github.com/OpenNHP/opennhp/blob/6e04ca5ff03222a699c24205cd4bf8fee9af7ffe/endpoints/agent/udpagent.go#L1335-L1371","documentation":"When refreshing the smart data policy for a non-decrypted data object, the agent needs a temp file path (utils.GenerateTempFilePath(\"plaintext-*\")); failure to create that path is wrapped as this error. It blocks decrypting the wrapped data key to disk before TA invocation.","triggerScenarios":"StartConfidentialComputing/AccessData path with decrypted==false where utils.GenerateTempFilePath fails — typically os.CreateTemp failing due to unwritable TMPDIR, full disk, or bad pattern.","commonSituations":"Read-only or missing temp directory (TMPDIR pointing to a nonexistent path); disk quota exceeded; container with no writable /tmp.","solutions":["Check TMPDIR/ os.TempDir() points to a writable existing directory","Free disk space / fix permissions on the temp directory","Inspect the wrapped error (%w) for the exact OS-level cause"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"tmp := os.TempDir()\nif fi, err := os.Stat(tmp); err != nil || !fi.IsDir() {\n    return fmt.Errorf(\"temp dir %s not usable: %v\", tmp, err)\n}","typeGuard":null,"tryCatchPattern":"out, err := a.StartConfidentialComputing(ztdoId, ...)\nif err != nil && strings.Contains(err.Error(), \"temporary file path\") {\n    log.Fatalf(\"fix TMPDIR/disk space: %v\", err)\n}","preventionTips":["Ensure TMPDIR exists and is writable in containers and CI","Monitor disk space on hosts running the agent","Verify os.TempDir() in constrained environments"],"tags":["filesystem","dhp","temp-file"],"backgroundTag":"file-write-failed","analyzedSha":"6e04ca5ff03222a699c24205cd4bf8fee9af7ffe","analyzedAt":"2026-09-07T15:44:59.941Z","contentChangedAt":"2026-09-07T15:44:59.941Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}