{"record":{"id":"512e6b1691f93a63","repo":"benbjohnson/litestream","slug":"invalid-level-must-be-0-d-or-all","errorCode":null,"errorMessage":"invalid level: must be 0-%d or \"all\"","messagePattern":"invalid level: must be 0-(.+?) or \"all\"","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/litestream/main.go","lineNumber":2201,"sourceCode":"type levelVar int\n\nvar _ flag.Value = (*levelVar)(nil)\n\nfunc (v *levelVar) String() string {\n\tif *v == levelAll {\n\t\treturn \"all\"\n\t}\n\treturn strconv.Itoa(int(*v))\n}\n\nfunc (v *levelVar) Set(s string) error {\n\tif s == \"all\" {\n\t\t*v = levelAll\n\t\treturn nil\n\t}\n\tn, err := strconv.Atoi(s)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"invalid level: must be 0-%d or \\\"all\\\"\", litestream.SnapshotLevel)\n\t}\n\tif n < 0 || n > litestream.SnapshotLevel {\n\t\treturn fmt.Errorf(\"level must be between 0 and %d\", litestream.SnapshotLevel)\n\t}\n\t*v = levelVar(n)\n\treturn nil\n}\n","sourceCodeStart":2183,"sourceCodeEnd":2209,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/cmd/litestream/main.go#L2183-L2209","documentation":"levelVar.Set implements flag.Value for the `litestream ltx -level` flag. If the argument is not the literal \"all\" and cannot be parsed as an integer, it reports that the level must be 0 through SnapshotLevel or \"all\".","triggerScenarios":"Running `litestream ltx -level snapshot` or `-level 0,1,2` or `-level ALL` (case-sensitive) — anything non-numeric and not exactly `all`.","commonSituations":"Assuming named levels like `snapshot` or `wal` are accepted; passing comma-separated lists; shell-cased `All` instead of lowercase `all`.","solutions":["Pass a plain integer between 0 and the max snapshot level (e.g. `-level 2`).","Use `-level all` (lowercase) to show every compaction level.","Run `litestream ltx -h` to confirm the accepted range shown in the flag usage."],"exampleFix":"// before\nlitestream ltx -level snapshot\n// after\nlitestream ltx -level all","handlingStrategy":"validation","validationCode":"// Accept only ints or the literal \"all\" before invoking the CLI\nif level != \"all\" {\n    if _, err := strconv.Atoi(level); err != nil {\n        return fmt.Errorf(\"-level must be an integer or 'all'\")\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := cmd.Run(); err != nil {\n    if strings.Contains(err.Error(), \"invalid level\") {\n        // fall back to -level all\n    }\n}","preventionTips":["Use numeric levels 0..N or the exact lowercase string `all`.","Check `litestream ltx -h` for the accepted range before scripting."],"tags":["cli","flag-parsing","level","ltx"],"backgroundTag":"invalid-flag-value","analyzedSha":"4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3","analyzedAt":"2026-09-06T18:29:25.564Z","contentChangedAt":"2026-09-06T18:29:25.564Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}