ipfs/kubo · error

ttl must not be negative, got %s

Error message

ttl must not be negative, got %s

What it means

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).

Source

Thrown at core/commands/name/publish.go:159

		opts := []options.NamePublishOption{
			options.Name.AllowOffline(allowOffline),
			options.Name.AllowDelegated(allowDelegated),
			options.Name.Key(kname),
			options.Name.ValidTime(validTime),
			options.Name.CompatibleWithV1(compatibleWithV1),
		}

		// A record is not cached past its validity, so the TTL must not exceed the
		// lifetime. An explicit --ttl over the lifetime is an error; the default
		// --ttl is capped to the lifetime instead.
		if ttl, found := req.Options[ttlOptionName].(string); found {
			d, err := time.ParseDuration(ttl)
			if err != nil {
				return err
			}
			if d < 0 {
				return fmt.Errorf("ttl must not be negative, got %s", ttl)
			}
			if d > validTime {
				return fmt.Errorf("ttl (%s) must not be greater than lifetime (%s)", d, validTime)
			}

			opts = append(opts, options.Name.TTL(d))
		} else {
			opts = append(opts, options.Name.TTL(min(ipns.DefaultRecordTTL, validTime)))
		}

		if sequence, found := req.Options[sequenceOptionName].(uint64); found {
			opts = append(opts, options.Name.Sequence(sequence))
		}

		p, err := cmdutils.PathOrCidPath(req.Arguments[0])
		if err != nil {
			return err
		}

View on GitHub (pinned to 329838acdf)

Solutions

  1. Use a non-negative duration such as 1m or 0s
  2. Omit --ttl to let it default (capped to the record lifetime)
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at core/commands/name/publish.go:159 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of ipfs/kubo@329838acdf (2026-09-03). Data as JSON: /api/errors/3e76ac884cd1d9de. Report an issue: GitHub.