{"record":{"id":"2f66c2a6d724d219","repo":"ipfs/kubo","slug":"s-can-t-be-used-with-unixfs-metadata-like-mode-or","errorCode":null,"errorMessage":"%s can't be used with UnixFS metadata like mode or modification time","messagePattern":"(.+?) can't be used with UnixFS metadata like mode or modification time","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/commands/add.go","lineNumber":434,"sourceCode":"\t\tfastProvideRoot = config.ResolveBoolFromConfig(fastProvideRoot, fastProvideRootSet, cfg.Import.FastProvideRoot, config.DefaultFastProvideRoot)\n\t\tfastProvideDAG = config.ResolveBoolFromConfig(fastProvideDAG, fastProvideDAGSet, cfg.Import.FastProvideDAG, config.DefaultFastProvideDAG)\n\t\tfastProvideWait = config.ResolveBoolFromConfig(fastProvideWait, fastProvideWaitSet, cfg.Import.FastProvideWait, config.DefaultFastProvideWait)\n\n\t\t// --only-hash does not store data, so pinning and providing\n\t\t// are meaningless.\n\t\tif onlyHash {\n\t\t\tdopin = false\n\t\t\tfastProvideRoot = false\n\t\t\tfastProvideDAG = false\n\t\t}\n\n\t\t// Storing optional mode or mtime (UnixFS 1.5) requires root block\n\t\t// to always be 'dag-pb' and not 'raw'. Below adjusts raw-leaves setting, if possible.\n\t\tif preserveMode || preserveMtime || mode != 0 || mtime != 0 {\n\t\t\t// Error if --raw-leaves flag was explicitly passed by the user.\n\t\t\t// (let user make a decision to manually disable it and retry)\n\t\t\tif rbset && rawblks {\n\t\t\t\treturn fmt.Errorf(\"%s can't be used with UnixFS metadata like mode or modification time\", rawLeavesOptionName)\n\t\t\t}\n\t\t\t// No explicit preference from user, disable raw-leaves and continue\n\t\t\trbset = true\n\t\t\trawblks = false\n\t\t}\n\n\t\tif onlyHash && toFilesSet {\n\t\t\treturn fmt.Errorf(\"%s and %s options are not compatible\", onlyHashOptionName, toFilesOptionName)\n\t\t}\n\t\tif !dopin && pinNameSet {\n\t\t\treturn fmt.Errorf(\"%s option requires %s to be set\", pinNameOptionName, pinOptionName)\n\t\t}\n\t\tif wrap && toFilesSet {\n\t\t\treturn fmt.Errorf(\"%s and %s options are not compatible\", wrapOptionName, toFilesOptionName)\n\t\t}\n\n\t\thashFunCode, ok := mh.Names[strings.ToLower(hashFunStr)]\n\t\tif !ok {","sourceCodeStart":416,"sourceCodeEnd":452,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/commands/add.go#L416-L452","documentation":"UnixFS 1.5 metadata (mode or mtime) must live in a dag-pb root node; --raw-leaves produces raw blocks that cannot carry this metadata. Kubo refuses the command when raw-leaves was explicitly requested together with mode/mtime metadata, so the user makes the choice consciously.","triggerScenarios":"`ipfs add --raw-leaves --preserve-mtime <path>`; `ipfs add --raw-leaves --mode=644 file`; any add where --raw-leaves was explicitly passed (or forced via config Import.UnixFSRawLeaves=true) alongside --mode, --mtime, --preserve-mode or --preserve-mtime.","commonSituations":"Archiving scripts preserving timestamps while enabling raw-leaves for deterministic CIDs; global config setting Import.UnixFSRawLeaves=true, then adding files with metadata flags.","solutions":["Remove --raw-leaves so kubo auto-disables it when metadata is present","Explicitly pass --raw-leaves=false to override config","Drop the mode/mtime/preserve flags if raw-leaves output matters more"],"exampleFix":"// before\nipfs add --raw-leaves --preserve-mtime ./photos\n// after\nipfs add --preserve-mtime ./photos","handlingStrategy":"validation","validationCode":"if rawLeaves && (mode != 0 || mtime != 0 || preserveMode || preserveMtime) {\n  return errors.New(\"--raw-leaves cannot be combined with mode/mtime metadata\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never set Import.UnixFSRawLeaves=true globally if metadata flags are used anywhere","Let kubo auto-disable raw-leaves (omit the flag) when metadata is present","Test the exact flag combination in CI before deploying scripts"],"tags":["cli","validation","unixfs","raw-leaves"],"backgroundTag":"incompatible-option-combination","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"}