{"record":{"id":"e95cf70351199503","repo":"multica-ai/multica","slug":"write-temp-for-s-w","errorCode":null,"errorMessage":"write temp for %s: %w","messagePattern":"write temp for (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/internal/daemon/execenv/hermes_home.go","lineNumber":923,"sourceCode":"\t\treturn fmt.Errorf(\"marshal hermes config: %w\", err)\n\t}\n\treturn writeFileAtomic(dst, out, 0o600)\n}\n\n// writeFileAtomic writes data to a temp file in the destination directory with\n// the given perms, then renames it over dst — so readers never see a partial\n// file and a prior file's looser permissions are replaced.\nfunc writeFileAtomic(dst string, data []byte, perm os.FileMode) error {\n\tdir := filepath.Dir(dst)\n\ttmp, err := os.CreateTemp(dir, \".hermes-tmp-*\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"create temp for %s: %w\", dst, err)\n\t}\n\ttmpName := tmp.Name()\n\tdefer os.Remove(tmpName) // no-op once renamed\n\tif _, err := tmp.Write(data); err != nil {\n\t\ttmp.Close()\n\t\treturn fmt.Errorf(\"write temp for %s: %w\", dst, err)\n\t}\n\tif err := tmp.Chmod(perm); err != nil {\n\t\ttmp.Close()\n\t\treturn fmt.Errorf(\"chmod temp for %s: %w\", dst, err)\n\t}\n\tif err := tmp.Close(); err != nil {\n\t\treturn fmt.Errorf(\"close temp for %s: %w\", dst, err)\n\t}\n\tif err := os.Rename(tmpName, dst); err != nil {\n\t\treturn fmt.Errorf(\"rename temp to %s: %w\", dst, err)\n\t}\n\treturn nil\n}\n","sourceCodeStart":905,"sourceCodeEnd":937,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/server/internal/daemon/execenv/hermes_home.go#L905-L937","documentation":"writeFileAtomic created the temp file but the initial Write of the payload failed. The data (derived config.yaml, marker, etc.) never made it to disk fully, so the atomic replace is abandoned and the temp file cleaned up by the deferred Remove.","triggerScenarios":"ENOSPC/EDQUOT hit mid-write; write timeout or I/O error on network-attached storage; file closed out from under the process by AV quarantine on Windows.","commonSituations":"Disk exactly full enough to create a temp file but not hold the payload; NFS/SMB jitter; security software intercepting writes of files that contain api_key-like secrets.","solutions":["Free disk space / raise quota on the destination volume and retry.","For network volumes, check mount health (`nfsstat`, dmesg) and prefer local disk for env RootDir.","Exclude the env root from AV real-time scanning on Windows.","Retry the task — transient write failures clear once the underlying condition is fixed."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"if free, err := statFreeSpace(filepath.Dir(dst)); err == nil && free < int64(len(data))+1<<20 {\n\treturn fmt.Errorf(\"insufficient space for %s: need ~%d bytes\", dst, int64(len(data)))\n}","typeGuard":null,"tryCatchPattern":"err := writeFileAtomic(dst, data, perm)\nif err != nil && strings.Contains(err.Error(), \"write temp\") {\n\t// ENOSPC/EDQUOT mid-write is often transient after cleanup — retry once\n\ttime.Sleep(100 * time.Millisecond)\n\terr = writeFileAtomic(dst, data, perm)\n}\nreturn err","preventionTips":["Keep headroom on the env volume; reserve space for temp-file writes.","For NFS/SMB destinations, prefer local scratch disks when reliability matters."],"tags":["filesystem","disk-full","io","atomic-write","hermes"],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}