{"record":{"id":"918dea420017a2df","repo":"ipfs/kubo","slug":"option-q-requires-q-to-be-provided-as-well","errorCode":null,"errorMessage":"option %q requires %q to be provided as well","messagePattern":"option %q requires %q to be provided as well","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/commands/add.go","lineNumber":497,"sourceCode":"\t\t\toptions.Unixfs.Nocopy(nocopy),\n\n\t\t\toptions.Unixfs.Progress(progress),\n\t\t\toptions.Unixfs.Silent(silent),\n\n\t\t\toptions.Unixfs.PreserveMode(preserveMode),\n\t\t\toptions.Unixfs.PreserveMtime(preserveMtime),\n\n\t\t\toptions.Unixfs.IncludeEmptyDirs(emptyDirs),\n\t\t}\n\n\t\tif mode != 0 {\n\t\t\topts = append(opts, options.Unixfs.Mode(os.FileMode(mode)))\n\t\t}\n\n\t\tif mtime != 0 {\n\t\t\topts = append(opts, options.Unixfs.Mtime(mtime, uint32(mtimeNsecs)))\n\t\t} else if mtimeNsecs != 0 {\n\t\t\treturn fmt.Errorf(\"option %q requires %q to be provided as well\", mtimeNsecsOptionName, mtimeOptionName)\n\t\t}\n\n\t\tif cidVerSet {\n\t\t\topts = append(opts, options.Unixfs.CidVersion(cidVer))\n\t\t}\n\n\t\tif rbset {\n\t\t\topts = append(opts, options.Unixfs.RawLeaves(rawblks))\n\t\t}\n\n\t\tif maxFileLinksSet {\n\t\t\topts = append(opts, options.Unixfs.MaxFileLinks(maxFileLinks))\n\t\t}\n\n\t\tif maxDirectoryLinksSet {\n\t\t\topts = append(opts, options.Unixfs.MaxDirectoryLinks(maxDirectoryLinks))\n\t\t}\n","sourceCodeStart":479,"sourceCodeEnd":515,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/commands/add.go#L479-L515","documentation":"`--mtime-nsecs` carries only the sub-second component of a modification time and requires `--mtime` (the seconds component) to be provided. Providing nsecs alone is rejected because it cannot represent a timestamp by itself.","triggerScenarios":"`ipfs add --mtime-nsecs=500 file`; RPC add with MtimeNsecs != 0 but Mtime == 0; a CLI builder that emits the nsecs flag without the base mtime flag.","commonSituations":"High-precision timestamp scripts computing nsecs but omitting the seconds component; hand-assembled API payloads where mtime is absent/0 while mtimeNsecs is set.","solutions":["Pass --mtime=<unix-seconds> together with --mtime-nsecs","Drop --mtime-nsecs if sub-second precision is not needed","In API clients, always send mtime and mtimeNsecs as a pair"],"exampleFix":"// before\nipfs add --mtime-nsecs=500 file.txt\n// after\nipfs add --mtime=1690000000 --mtime-nsecs=500 file.txt","handlingStrategy":"validation","validationCode":"if mtimeNsecs != 0 && mtime == 0 {\n  return errors.New(\"--mtime-nsecs requires --mtime to be set\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always emit mtime and mtimeNsecs together from timestamp-producing code","Derive both from one time.Time value (t.Unix(), t.Nanosecond())"],"tags":["cli","validation","unixfs","metadata"],"backgroundTag":"option-requires-companion-option","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"}