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
- Use 0 to disable trash: `--trash-days 0`
- Use a positive integer for the desired retention period
- 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
- Use 0 to disable trash, never negatives
- Validate numbers before passing to CLI
- Avoid signed arithmetic when computing retention days
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
- tier should be between 0 and 3
- negative duration for %s: %s
- negative value for %s: %d
- Invalid version string: %s
- restore command requires Administrator or elevated privilege
AI-assisted analysis of juicedata/juicefs@c9a67b23e8 (2026-09-06).
Data as JSON: /api/errors/7896087a392886c0.
Report an issue: GitHub.