juicedata/juicefs · error

Invalid trash days: %d

Error message

Invalid trash days: %d

What it means

`juicefs config` validates the new `--trash-days` value: a negative number is meaningless for trash retention and is rejected with 'Invalid trash days: %d'. Only 0 (disable trash) or a positive day count is accepted.

Source

Thrown at cmd/config.go:301

				newTier.Tag = new
				format.Tiers[0] = newTier
				storage = true
				tier = true
			}
		case "upload-limit":
			if new := utils.ParseMbps(ctx, flag); new != format.UploadLimit {
				msg.WriteString(fmt.Sprintf("%10s: %s -> %s\n", flag, utils.Mbps(format.UploadLimit), utils.Mbps(new)))
				format.UploadLimit = new
			}
		case "download-limit":
			if new := utils.ParseMbps(ctx, flag); new != format.DownloadLimit {
				msg.WriteString(fmt.Sprintf("%10s: %s -> %s\n", flag, utils.Mbps(format.DownloadLimit), utils.Mbps(new)))
				format.DownloadLimit = new
			}
		case "trash-days":
			if new := ctx.Int(flag); new != format.TrashDays {
				if new < 0 {
					return fmt.Errorf("Invalid trash days: %d", new)
				}
				msg.WriteString(fmt.Sprintf("%10s: %d -> %d\n", flag, format.TrashDays, new))
				format.TrashDays = new
				trash = true
			}
		case "dir-stats":
			if new := ctx.Bool(flag); new != format.DirStats {
				msg.WriteString(fmt.Sprintf("%10s: %t -> %t\n", flag, format.DirStats, new))
				format.DirStats = new
			}
		case "changelog":
			if new := ctx.Bool(flag); new != format.ChangeLog {
				msg.WriteString(fmt.Sprintf("%10s: %t -> %t\n", flag, format.ChangeLog, new))
				format.ChangeLog = new
				if new && format.ChangeLogMaxAge == 0 && !ctx.IsSet("changelog-max-age") {
					format.ChangeLogMaxAge = 7200
					msg.WriteString(fmt.Sprintf("%10s: 0s -> %s (default)\n", "changelog-max-age", time.Duration(7200)*time.Second))
				}

View on GitHub (pinned to c9a67b23e8)

Solutions

  1. Use 0 to disable trash: `--trash-days 0`
  2. Use a positive integer for the desired retention period
  3. Fix the script variable so it cannot go negative

Example fix

// before
juicefs config sqlite3://test.db --trash-days -7
// after
juicefs config sqlite3://test.db --trash-days 7
Defensive patterns

Strategy: validation

Validate before calling

if [ "$TRASH_DAYS" -lt 0 ]; then die "trash-days must be >= 0"; fi

Prevention

When it happens

Trigger: `juicefs config META --trash-days -1` or any negative value passed to --trash-days.

Common situations: Trying to 'disable' trash with a negative value instead of 0; script bugs computing trash-days; copy-paste from a config using different sign conventions.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


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