juicedata/juicefs · error

--days should be at least 1

Error message

--days should be at least 1

What it means

The `juicefs tier` command validates the --days flag (how long a restored object stays in restored state) via a cli flag Action callback. A value below 1 is rejected because a 0 or negative retention makes no sense for object-storage restore semantics. Fail-fast validation before any metadata or object operations.

Source

Thrown at cmd/tier.go:102

				Name:    "recursive",
				Aliases: []string{"r"},
				Usage:   "recursively set storage tier for all files and directories under the target directory",
			},
			&cli.BoolFlag{
				Name:    "force",
				Aliases: []string{"f"},
				Usage:   "force rewriting objects to the tier's current storage class (useful after --storage-class config changes), even when the tier id is unchanged",
			},
			&cli.IntFlag{
				Name:  "days",
				Value: object.DefaultRestoreDays,
				Usage: "the duration within which the restored object remains in the restored state",
				Action: func(ctx *cli.Context, v int) error {
					if !ctx.IsSet("days") {
						return nil
					}
					if v < 1 {
						return fmt.Errorf("--days should be at least 1")
					}
					return nil
				},
			},
		},
	}
}

func listTier(ctx *cli.Context) error {
	setup(ctx, 1)
	removePassword(ctx.Args().Get(0))
	m := meta.NewClient(ctx.Args().Get(0), nil)
	format, err := m.Load(true)
	if err != nil {
		logger.Fatalf("load setting: %s", err)
	}
	results := make([][]string, 0, 1+len(format.Tiers))
	results = append(results, []string{"tier", "storageClass", "tag"})

View on GitHub (pinned to c9a67b23e8)

Solutions

  1. Pass --days with a value of at least 1.
  2. If a shorter restore window is desired, note that object storage restore APIs enforce a minimum of 1 day anyway.
  3. Omit --days entirely to use the default retention behavior.

Example fix

// before
juicefs tier sqlite3://test.db --days 0
// after
juicefs tier sqlite3://test.db --days 1
Defensive patterns

Strategy: validation

Validate before calling

if days < 1 {
    return fmt.Errorf("--days must be at least 1, got %d", days)
}

Prevention

When it happens

Trigger: `juicefs tier <meta-url> --days 0` or a negative value such as --days -3.

Common situations: Script computing days from a date difference that rounds to 0; user confusing --days with hours; copy-pasted flags from other tools where 0 means 'default'.

Understand the failure class

Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.

Related errors


AI-assisted analysis of juicedata/juicefs@c9a67b23e8 (2026-09-06). Data as JSON: /api/errors/b94a6ace0af58b94. Report an issue: GitHub.