{"record":{"id":"2eb4b751ab783bcb","repo":"ipfs/kubo","slug":"ttl-s-must-not-be-greater-than-lifetime-s","errorCode":null,"errorMessage":"ttl (%s) must not be greater than lifetime (%s)","messagePattern":"ttl \\((.+?)\\) must not be greater than lifetime \\((.+?)\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/commands/name/publish.go","lineNumber":162,"sourceCode":"\t\t\toptions.Name.AllowDelegated(allowDelegated),\n\t\t\toptions.Name.Key(kname),\n\t\t\toptions.Name.ValidTime(validTime),\n\t\t\toptions.Name.CompatibleWithV1(compatibleWithV1),\n\t\t}\n\n\t\t// A record is not cached past its validity, so the TTL must not exceed the\n\t\t// lifetime. An explicit --ttl over the lifetime is an error; the default\n\t\t// --ttl is capped to the lifetime instead.\n\t\tif ttl, found := req.Options[ttlOptionName].(string); found {\n\t\t\td, err := time.ParseDuration(ttl)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif d < 0 {\n\t\t\t\treturn fmt.Errorf(\"ttl must not be negative, got %s\", ttl)\n\t\t\t}\n\t\t\tif d > validTime {\n\t\t\t\treturn fmt.Errorf(\"ttl (%s) must not be greater than lifetime (%s)\", d, validTime)\n\t\t\t}\n\n\t\t\topts = append(opts, options.Name.TTL(d))\n\t\t} else {\n\t\t\topts = append(opts, options.Name.TTL(min(ipns.DefaultRecordTTL, validTime)))\n\t\t}\n\n\t\tif sequence, found := req.Options[sequenceOptionName].(uint64); found {\n\t\t\topts = append(opts, options.Name.Sequence(sequence))\n\t\t}\n\n\t\tp, err := cmdutils.PathOrCidPath(req.Arguments[0])\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif verifyExists, _ := req.Options[resolveOptionName].(bool); verifyExists {\n\t\t\t_, err := api.ResolveNode(req.Context, p)","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/commands/name/publish.go#L144-L180","documentation":"`ipfs name publish` validates that an explicitly passed `--ttl` duration does not exceed the record's `--lifetime` (which defaults to ipns.DefaultRecordLifetime). IPNS records are not cached past their validity, so a TTL longer than the lifetime is contradictory and rejected at publish time before any record is signed or broadcast.","triggerScenarios":"Running `ipfs name publish --ttl <d> ...` where the parsed ttl duration d > validTime, i.e. the user passed --ttl greater than the --lifetime value (or greater than the default lifetime when --lifetime is unset).","commonSituations":"Users copying a --ttl from an example with a large value like 168h while --lifetime defaults to 24h; scripts setting --ttl but forgetting to raise --lifetime to match; confusion between TTL semantics (cache freshness) and lifetime (record validity).","solutions":["Raise --lifetime to a value >= --ttl (e.g. `ipfs name publish --lifetime=168h --ttl=168h <path>`).","Lower --ttl to at most the current lifetime (default 24h), or omit --ttl and let kubo cap it with min(DefaultRecordTTL, lifetime).","Fix any script that computes ttl/lifetime so it asserts ttl <= lifetime before invoking the command."],"exampleFix":"// before\nipfs name publish --ttl=72h /ipfs/<cid>            // fails: default lifetime is 24h\n// after\nipfs name publish --lifetime=72h --ttl=72h /ipfs/<cid>","handlingStrategy":"validation","validationCode":"lifetime, _ := time.ParseDuration(\"24h\")\nttl, _ := time.ParseDuration(\"72h\")\nif ttl > lifetime {\n    return fmt.Errorf(\"ttl (%s) must not exceed lifetime (%s)\", ttl, lifetime)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass --lifetime together with --ttl so their relationship is explicit.","Clamp ttl to min(ttl, lifetime) in wrapper scripts before invoking the command.","Remember the default lifetime is 24h; any --ttl over that must raise --lifetime too."],"tags":["ipns","cli","validation"],"backgroundTag":"ttl-exceeds-lifetime","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"}