ipfs/kubo · error
option %q requires %q to be provided as well
Error message
option %q requires %q to be provided as well
What it means
`--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.
Source
Thrown at core/commands/add.go:497
options.Unixfs.Nocopy(nocopy),
options.Unixfs.Progress(progress),
options.Unixfs.Silent(silent),
options.Unixfs.PreserveMode(preserveMode),
options.Unixfs.PreserveMtime(preserveMtime),
options.Unixfs.IncludeEmptyDirs(emptyDirs),
}
if mode != 0 {
opts = append(opts, options.Unixfs.Mode(os.FileMode(mode)))
}
if mtime != 0 {
opts = append(opts, options.Unixfs.Mtime(mtime, uint32(mtimeNsecs)))
} else if mtimeNsecs != 0 {
return fmt.Errorf("option %q requires %q to be provided as well", mtimeNsecsOptionName, mtimeOptionName)
}
if cidVerSet {
opts = append(opts, options.Unixfs.CidVersion(cidVer))
}
if rbset {
opts = append(opts, options.Unixfs.RawLeaves(rawblks))
}
if maxFileLinksSet {
opts = append(opts, options.Unixfs.MaxFileLinks(maxFileLinks))
}
if maxDirectoryLinksSet {
opts = append(opts, options.Unixfs.MaxDirectoryLinks(maxDirectoryLinks))
}
View on GitHub (pinned to 329838acdf)
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
Example fix
// before ipfs add --mtime-nsecs=500 file.txt // after ipfs add --mtime=1690000000 --mtime-nsecs=500 file.txt
Defensive patterns
Strategy: validation
Validate before calling
if mtimeNsecs != 0 && mtime == 0 {
return errors.New("--mtime-nsecs requires --mtime to be set")
} Prevention
- Always emit mtime and mtimeNsecs together from timestamp-producing code
- Derive both from one time.Time value (t.Unix(), t.Nanosecond())
When it happens
Trigger: `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.
Common situations: High-precision timestamp scripts computing nsecs but omitting the seconds component; hand-assembled API payloads where mtime is absent/0 while mtimeNsecs is set.
Related errors
- %s can't be used with UnixFS metadata like mode or modificat
- invalid configuration profile: %s
- Import.UnixFSFileMaxLinks must be positive, got %d
- Import.UnixFSDirectoryMaxLinks must be non-negative, got %d
- Import.UnixFSHAMTDirectoryMaxFanout must be a power of 2, be
AI-assisted analysis of ipfs/kubo@329838acdf (2026-09-03).
Data as JSON: /api/errors/918dea420017a2df.
Report an issue: GitHub.