{"record":{"id":"c300a19e874d83e9","repo":"ipfs/kubo","slug":"files-rm-always-flushes-for-safety-the-flush-fl","errorCode":null,"errorMessage":"files rm always flushes for safety. The --flush flag cannot be set to false for this command","messagePattern":"files rm always flushes for safety\\. The --flush flag cannot be set to false for this command","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/commands/files.go","lineNumber":1393,"sourceCode":"    cat\n    dog\n    fish\n    $ ipfs files rm -r /bar\n`,\n\t},\n\n\tArguments: []cmds.Argument{\n\t\tcmds.StringArg(\"path\", true, true, \"File to remove.\"),\n\t},\n\tOptions: []cmds.Option{\n\t\tcmds.BoolOption(recursiveOptionName, \"r\", \"Recursively remove directories.\"),\n\t\tcmds.BoolOption(forceOptionName, \"Forcibly remove target at path; implies -r for directories\"),\n\t},\n\tRun: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {\n\t\t// Check if user explicitly set --flush=false\n\t\tif flushOpt, ok := req.Options[filesFlushOptionName]; ok {\n\t\t\tif flush, ok := flushOpt.(bool); ok && !flush {\n\t\t\t\treturn fmt.Errorf(\"files rm always flushes for safety. The --flush flag cannot be set to false for this command\")\n\t\t\t}\n\t\t}\n\n\t\tnd, err := cmdenv.GetNode(env)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tdefer mfsPinLock(nd, req.Context).Unlock(req.Context)\n\t\t// if '--force' specified, it will remove anything else,\n\t\t// including file, directory, corrupted node, etc\n\t\tforce, _ := req.Options[forceOptionName].(bool)\n\t\tdashr, _ := req.Options[recursiveOptionName].(bool)\n\t\tvar errs []error\n\t\tfor _, arg := range req.Arguments {\n\t\t\tpath, err := checkPath(arg)\n\t\t\tif err != nil {\n\t\t\t\terrs = append(errs, fmt.Errorf(\"%s is not a valid path: %w\", arg, err))\n\t\t\t\tcontinue","sourceCodeStart":1375,"sourceCodeEnd":1411,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/commands/files.go#L1375-L1411","documentation":"Precondition check in the `ipfs files rm` handler: the command inspects whether the caller explicitly passed --flush=false and rejects it. `files rm` always flushes the affected parent directories so removals are persisted immediately; disabling flush for a destructive operation is disallowed by design, not an operational failure.","triggerScenarios":"Thrown at core/commands/files.go:1393 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Do not pass --flush=false with `ipfs files rm`; accept the default flush behavior.","For non-flushing write workflows use `ipfs files write`/`mkdir` with --flush=false instead."],"exampleFix":null,"handlingStrategy":"validation","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"}