{"record":{"id":"e5619be7cd4866a2","repo":"ipfs/kubo","slug":"file-rename-error-w-file-remove-error-s","errorCode":null,"errorMessage":"file Rename error: %w, file remove error: %s","messagePattern":"file Rename error: %w, file remove error: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"repo/fsrepo/fsrepo.go","lineNumber":449,"sourceCode":"\t}()\n\tdefer f.Close()\n\n\tif _, err := fmt.Fprintf(f, \"http://%s\", addr.String()); err != nil {\n\t\treturn err\n\t}\n\tif err := f.Close(); err != nil {\n\t\treturn err\n\t}\n\n\t// Atomically rename the temp file to the correct file name.\n\terr = os.Rename(tmpPath, filepath.Join(r.path, gatewayFile))\n\tgood = err == nil\n\tif good {\n\t\treturn nil\n\t}\n\t// Remove the temp file when rename return error\n\tif err1 := os.Remove(tmpPath); err1 != nil {\n\t\treturn fmt.Errorf(\"file Rename error: %w, file remove error: %s\", err, err1.Error())\n\t}\n\treturn err\n}\n\n// openConfig returns an error if the config file is not present.\nfunc (r *FSRepo) openConfig() error {\n\tconf, err := serialize.Load(r.configFilePath)\n\tif err != nil {\n\t\treturn err\n\t}\n\tr.config = conf\n\treturn nil\n}\n\n// openUserResourceOverrides will remove all overrides if the file is not present.\n// It will error if the decoding fails.\nfunc (r *FSRepo) openUserResourceOverrides() error {\n\t// This filepath is documented in docs/libp2p-resource-management.md and be kept in sync.","sourceCodeStart":431,"sourceCodeEnd":467,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/repo/fsrepo/fsrepo.go#L431-L467","documentation":"Fired by FSRepo.SetGatewayAddr when the atomic rename of the temp file holding the gateway address fails AND the subsequent cleanup os.Remove of that temp file also fails. The message carries both errors: the original rename error (%w) and the remove error, so the failed temp file's existence is visible.","triggerScenarios":"Thrown at repo/fsrepo/fsrepo.go:449 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Delete the leftover temp file for the gateway address in the repo directory","Check filesystem permissions and disk health","Restart the daemon to retry the write"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"329838acdfafae224582930457efe80aa217afc0","analyzedAt":"2026-09-03T18:30:52.135Z","contentChangedAt":"2026-09-03T18:30:52.135Z","schemaVersion":2},"datasetVersion":"2026-09-11T00:17:11.886Z"}