{"record":{"id":"b94a6ace0af58b94","repo":"juicedata/juicefs","slug":"days-should-be-at-least-1","errorCode":null,"errorMessage":"--days should be at least 1","messagePattern":"--days should be at least 1","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/tier.go","lineNumber":102,"sourceCode":"\t\t\t\tName:    \"recursive\",\n\t\t\t\tAliases: []string{\"r\"},\n\t\t\t\tUsage:   \"recursively set storage tier for all files and directories under the target directory\",\n\t\t\t},\n\t\t\t&cli.BoolFlag{\n\t\t\t\tName:    \"force\",\n\t\t\t\tAliases: []string{\"f\"},\n\t\t\t\tUsage:   \"force rewriting objects to the tier's current storage class (useful after --storage-class config changes), even when the tier id is unchanged\",\n\t\t\t},\n\t\t\t&cli.IntFlag{\n\t\t\t\tName:  \"days\",\n\t\t\t\tValue: object.DefaultRestoreDays,\n\t\t\t\tUsage: \"the duration within which the restored object remains in the restored state\",\n\t\t\t\tAction: func(ctx *cli.Context, v int) error {\n\t\t\t\t\tif !ctx.IsSet(\"days\") {\n\t\t\t\t\t\treturn nil\n\t\t\t\t\t}\n\t\t\t\t\tif v < 1 {\n\t\t\t\t\t\treturn fmt.Errorf(\"--days should be at least 1\")\n\t\t\t\t\t}\n\t\t\t\t\treturn nil\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t}\n}\n\nfunc listTier(ctx *cli.Context) error {\n\tsetup(ctx, 1)\n\tremovePassword(ctx.Args().Get(0))\n\tm := meta.NewClient(ctx.Args().Get(0), nil)\n\tformat, err := m.Load(true)\n\tif err != nil {\n\t\tlogger.Fatalf(\"load setting: %s\", err)\n\t}\n\tresults := make([][]string, 0, 1+len(format.Tiers))\n\tresults = append(results, []string{\"tier\", \"storageClass\", \"tag\"})","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/cmd/tier.go#L84-L120","documentation":"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.","triggerScenarios":"`juicefs tier <meta-url> --days 0` or a negative value such as --days -3.","commonSituations":"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'.","solutions":["Pass --days with a value of at least 1.","If a shorter restore window is desired, note that object storage restore APIs enforce a minimum of 1 day anyway.","Omit --days entirely to use the default retention behavior."],"exampleFix":"// before\njuicefs tier sqlite3://test.db --days 0\n// after\njuicefs tier sqlite3://test.db --days 1","handlingStrategy":"validation","validationCode":"if days < 1 {\n    return fmt.Errorf(\"--days must be at least 1, got %d\", days)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Compute --days with a ceiling (never floor to 0) from date differences","Omit --days to accept the default retention instead of passing 0"],"tags":["cli","validation","tier","argument"],"backgroundTag":"value-out-of-range","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"}