{"record":{"id":"a25879c28e5a87ef","repo":"juicedata/juicefs","slug":"tier-should-be-between-0-and-3-a25879","errorCode":null,"errorMessage":"--tier should be between 0 and 3","messagePattern":"--tier should be between 0 and 3","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/tier.go","lineNumber":78,"sourceCode":"\t\t\t\tAction:    setTier,\n\t\t\t},\n\t\t\t{\n\t\t\t\tName:      \"restore\",\n\t\t\t\tUsage:     \"restore objects of a file or directory\",\n\t\t\t\tArgsUsage: \"META-URL PATH\",\n\t\t\t\tAction:    objRestore,\n\t\t\t},\n\t\t},\n\t\tFlags: []cli.Flag{\n\t\t\t&cli.IntFlag{\n\t\t\t\tName:  \"tier\",\n\t\t\t\tUsage: \"tier (0-3, 0 is reserved for default tier)\",\n\t\t\t\tAction: func(ctx *cli.Context, v int) error {\n\t\t\t\t\tif !ctx.IsSet(\"tier\") {\n\t\t\t\t\t\treturn nil\n\t\t\t\t\t}\n\t\t\t\t\tif v < 0 || v > 3 {\n\t\t\t\t\t\treturn fmt.Errorf(\"--tier should be between 0 and 3\")\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\t&cli.BoolFlag{\n\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\",","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/cmd/tier.go#L60-L96","documentation":"The `juicefs tier` command validates the --tier flag with a cli flag Action callback. Storage classes map to tiers 0-3 (0 reserved for the default tier), so any --tier value outside that range is rejected before the command runs. This is a fail-fast CLI argument validation error.","triggerScenarios":"`juicefs tier <meta-url> --tier 4` (or any negative value, e.g. --tier -1).","commonSituations":"Users guessing at tier numbering from an object store's storage-class IDs (which may exceed 3); scripting the command with a computed tier that overflows the range; typos such as --tier 13.","solutions":["Use a tier value between 0 and 3 inclusive.","Check the volume's configured storage classes (`juicefs config`) to map the desired storage class to a valid tier.","If a higher tier is genuinely needed, the range must be changed in cmd/tier.go and the volume's tier configuration — this is a code/config change, not a CLI workaround."],"exampleFix":"// before\njuicefs tier sqlite3://test.db --tier 5\n// after\njuicefs tier sqlite3://test.db --tier 3","handlingStrategy":"validation","validationCode":"if tier < 0 || tier > 3 {\n    return fmt.Errorf(\"--tier must be 0-3, got %d\", tier)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Map the object store's storage-class IDs to JuiceFS tiers before scripting","Check `juicefs config` output for the volume's configured tiers","Clamp computed tier values to [0,3] in scripts"],"tags":["cli","validation","tier","argument"],"backgroundTag":"invalid-cli-argument","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"}