{"record":{"id":"0e135faa451669b4","repo":"ory/hydra","slug":"value-for-batch-size-must-not-be-greater-than-va","errorCode":null,"errorMessage":"Value for --batch-size must not be greater than value for --limit","messagePattern":"Value for --batch-size must not be greater than value for --limit","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/cli/handler_janitor.go","lineNumber":74,"sourceCode":"\t\t\t\"- Using the config file with flag -c, --config\")\n\t}\n\n\tif !flagx.MustGetBool(cmd, OnlyTokens) && !flagx.MustGetBool(cmd, OnlyRequests) && !flagx.MustGetBool(cmd, OnlyGrants) {\n\t\t//lint:ignore ST1005 formatted error string used in CLI output\n\t\treturn fmt.Errorf(\"%s\\n%s\\n\", cmd.UsageString(),\n\t\t\t\"Janitor requires at least one of --tokens, --requests or --grants to be set\")\n\t}\n\n\tlimit := flagx.MustGetInt(cmd, Limit)\n\tbatchSize := flagx.MustGetInt(cmd, BatchSize)\n\tif limit <= 0 || batchSize <= 0 {\n\t\t//lint:ignore ST1005 formatted error string used in CLI output\n\t\treturn fmt.Errorf(\"%s\\n%s\\n\", cmd.UsageString(),\n\t\t\t\"Values for --limit and --batch-size should both be greater than 0\")\n\t}\n\tif batchSize > limit {\n\t\t//lint:ignore ST1005 formatted error string used in CLI output\n\t\treturn fmt.Errorf(\"%s\\n%s\\n\", cmd.UsageString(),\n\t\t\t\"Value for --batch-size must not be greater than value for --limit\")\n\t}\n\n\treturn nil\n}\n\nfunc (j *JanitorHandler) RunE(cmd *cobra.Command, args []string) error {\n\treturn purge(cmd, args, j.dOpts)\n}\n\nfunc purge(cmd *cobra.Command, args []string, dOpts []driver.OptionsModifier) error {\n\tctx := cmd.Context()\n\n\tco := []configx.OptionModifier{\n\t\tconfigx.WithFlags(cmd.Flags()),\n\t\tconfigx.SkipValidation(),\n\t}\n","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/ory/hydra/blob/4174065ffb052799890f7480f5360a877a67ffc1/cmd/cli/handler_janitor.go#L56-L92","documentation":"Janitor deletes in batches of --batch-size until --limit rows are removed; a batch size larger than the limit is inconsistent with that paging contract, so Args rejects it with this formatted CLI error.","triggerScenarios":"Running `hydra janitor ... --batch-size 500 --limit 100` (batchSize > limit).","commonSituations":"Tuning one flag without the other in a scheduled job; copying examples where batch-size default (100) exceeds a small custom limit; confusion about which flag bounds the other.","solutions":["Set --limit >= --batch-size, e.g. --limit 500 --batch-size 100.","Or simply raise --limit if you actually want more rows deleted per run.","Or lower --batch-size to match the intended per-run cap.","Align both values in the CronJob manifest/script in one place."],"exampleFix":"// before\nhydra janitor $DSN --tokens --limit 100 --batch-size 500\n\n// after\nhydra janitor $DSN --tokens --limit 500 --batch-size 100","handlingStrategy":"validation","validationCode":"if [ \"$BATCH\" -gt \"$LIMIT\" ]; then\n  echo \"--batch-size must not exceed --limit\" >&2; exit 1\nfi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Define limit and batch-size together in one config variable pair.","Convention: batch-size = limit/5 or a fixed 100, always <= limit.","Change both flags together when tuning janitor throughput.","Add a CI check validating the relationship in manifests."],"tags":["cli","janitor","arguments","validation"],"backgroundTag":"invalid-flag-value","analyzedSha":"4174065ffb052799890f7480f5360a877a67ffc1","analyzedAt":"2026-09-03T14:52:41.581Z","contentChangedAt":"2026-09-03T14:52:41.581Z","schemaVersion":2},"datasetVersion":"2026-09-10T17:17:09.494Z"}