{"record":{"id":"f8aa7ab1b9dd6c0b","repo":"multica-ai/multica","slug":"close-temp-config-file-w","errorCode":null,"errorMessage":"close temp config file: %w","messagePattern":"close temp config file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/internal/cli/config.go","lineNumber":366,"sourceCode":"\tdata, err := json.MarshalIndent(cfg, \"\", \"  \")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"encode CLI config: %w\", err)\n\t}\n\n\t// Write to a temp file in the same directory, then rename for atomicity.\n\ttmp, err := os.CreateTemp(dir, \".config-*.json.tmp\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"create temp config file: %w\", err)\n\t}\n\ttmpPath := tmp.Name()\n\tif _, err := tmp.Write(append(data, '\\n')); err != nil {\n\t\ttmp.Close()\n\t\tos.Remove(tmpPath)\n\t\treturn fmt.Errorf(\"write temp config file: %w\", err)\n\t}\n\tif err := tmp.Close(); err != nil {\n\t\tos.Remove(tmpPath)\n\t\treturn fmt.Errorf(\"close temp config file: %w\", err)\n\t}\n\tif err := os.Chmod(tmpPath, 0o600); err != nil {\n\t\tos.Remove(tmpPath)\n\t\treturn fmt.Errorf(\"chmod temp config file: %w\", err)\n\t}\n\tif err := os.Rename(tmpPath, path); err != nil {\n\t\tos.Remove(tmpPath)\n\t\treturn fmt.Errorf(\"rename config file: %w\", err)\n\t}\n\treturn nil\n}\n","sourceCodeStart":348,"sourceCodeEnd":378,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/server/internal/cli/config.go#L348-L378","documentation":"The temp file's Close() returned an error after a successful write. On local filesystems this is rare; on NFS or FUSE mounts close can surface deferred write errors (data could not be flushed). The temp file is removed and the save aborted, leaving the previous config untouched.","triggerScenarios":"Saving the config onto an NFS/FUSE mount where flushing at close fails; a filesystem returning EIO at flush time after a device error.","commonSituations":"MULTICA_TASK_CONFIG_ROOT on network storage; laptops with failing disks; fuse overlay filesystems with quota enforcement at flush.","solutions":["Move the config storage to a local filesystem or fix the network mount","Check system logs for the underlying I/O error","Retry after remounting the filesystem read-write and healthy","Verify quota limits if the mount enforces per-user quotas at flush"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := cli.SaveCLIConfig(cfg); err != nil && strings.Contains(err.Error(), \"close temp config file\") {\n\t// likely network-filesystem flush failure; retry after remount or move root to local disk\n}","preventionTips":["Keep the config root on a local filesystem rather than NFS/FUSE","Check mount health before scheduled config-heavy operations","Old config survives a failed close — safe to retry"],"tags":["filesystem","io","nfs","go"],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}