{"record":{"id":"7896087a392886c0","repo":"juicedata/juicefs","slug":"invalid-trash-days-d","errorCode":null,"errorMessage":"Invalid trash days: %d","messagePattern":"Invalid trash days: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/config.go","lineNumber":301,"sourceCode":"\t\t\t\tnewTier.Tag = new\n\t\t\t\tformat.Tiers[0] = newTier\n\t\t\t\tstorage = true\n\t\t\t\ttier = true\n\t\t\t}\n\t\tcase \"upload-limit\":\n\t\t\tif new := utils.ParseMbps(ctx, flag); new != format.UploadLimit {\n\t\t\t\tmsg.WriteString(fmt.Sprintf(\"%10s: %s -> %s\\n\", flag, utils.Mbps(format.UploadLimit), utils.Mbps(new)))\n\t\t\t\tformat.UploadLimit = new\n\t\t\t}\n\t\tcase \"download-limit\":\n\t\t\tif new := utils.ParseMbps(ctx, flag); new != format.DownloadLimit {\n\t\t\t\tmsg.WriteString(fmt.Sprintf(\"%10s: %s -> %s\\n\", flag, utils.Mbps(format.DownloadLimit), utils.Mbps(new)))\n\t\t\t\tformat.DownloadLimit = new\n\t\t\t}\n\t\tcase \"trash-days\":\n\t\t\tif new := ctx.Int(flag); new != format.TrashDays {\n\t\t\t\tif new < 0 {\n\t\t\t\t\treturn fmt.Errorf(\"Invalid trash days: %d\", new)\n\t\t\t\t}\n\t\t\t\tmsg.WriteString(fmt.Sprintf(\"%10s: %d -> %d\\n\", flag, format.TrashDays, new))\n\t\t\t\tformat.TrashDays = new\n\t\t\t\ttrash = true\n\t\t\t}\n\t\tcase \"dir-stats\":\n\t\t\tif new := ctx.Bool(flag); new != format.DirStats {\n\t\t\t\tmsg.WriteString(fmt.Sprintf(\"%10s: %t -> %t\\n\", flag, format.DirStats, new))\n\t\t\t\tformat.DirStats = new\n\t\t\t}\n\t\tcase \"changelog\":\n\t\t\tif new := ctx.Bool(flag); new != format.ChangeLog {\n\t\t\t\tmsg.WriteString(fmt.Sprintf(\"%10s: %t -> %t\\n\", flag, format.ChangeLog, new))\n\t\t\t\tformat.ChangeLog = new\n\t\t\t\tif new && format.ChangeLogMaxAge == 0 && !ctx.IsSet(\"changelog-max-age\") {\n\t\t\t\t\tformat.ChangeLogMaxAge = 7200\n\t\t\t\t\tmsg.WriteString(fmt.Sprintf(\"%10s: 0s -> %s (default)\\n\", \"changelog-max-age\", time.Duration(7200)*time.Second))\n\t\t\t\t}","sourceCodeStart":283,"sourceCodeEnd":319,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/cmd/config.go#L283-L319","documentation":"`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.","triggerScenarios":"`juicefs config META --trash-days -1` or any negative value passed to --trash-days.","commonSituations":"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.","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"],"exampleFix":"// before\njuicefs config sqlite3://test.db --trash-days -7\n// after\njuicefs config sqlite3://test.db --trash-days 7","handlingStrategy":"validation","validationCode":"if [ \"$TRASH_DAYS\" -lt 0 ]; then die \"trash-days must be >= 0\"; fi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use 0 to disable trash, never negatives","Validate numbers before passing to CLI","Avoid signed arithmetic when computing retention days"],"tags":["cli","validation","trash"],"backgroundTag":"invalid-config-value","analyzedSha":"c9a67b23e8e08ec23ec331aa6f1675e2319e921c","analyzedAt":"2026-09-06T17:55:48.476Z","contentChangedAt":"2026-09-06T17:55:48.476Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}