{"record":{"id":"3e76ac884cd1d9de","repo":"ipfs/kubo","slug":"ttl-must-not-be-negative-got-s","errorCode":null,"errorMessage":"ttl must not be negative, got %s","messagePattern":"ttl must not be negative, got (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/commands/name/publish.go","lineNumber":159,"sourceCode":"\n\t\topts := []options.NamePublishOption{\n\t\t\toptions.Name.AllowOffline(allowOffline),\n\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}","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/commands/name/publish.go#L141-L177","documentation":"The --ttl option parsed to a negative duration. TTL is used for caching; a negative TTL is meaningless and rejected before publishing (an explicit ttl above the lifetime is also an error, while the default ttl is capped instead).","triggerScenarios":"Thrown at core/commands/name/publish.go:159 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use a non-negative duration such as 1m or 0s","Omit --ttl to let it default (capped to the record lifetime)"],"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"}