{"record":{"id":"accb5d3d1b9ea58e","repo":"signalapp/Signal-Server","slug":"range-split-chunk-size-bytes-must-be-positive","errorCode":null,"errorMessage":"range-split-chunk-size-bytes must be positive","messagePattern":"range-split-chunk-size-bytes must be positive","errorType":"console","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"service/src/main/java/org/whispersystems/textsecuregcm/workers/TrimOversizedFoundationDbMessageQueuesCommand.java","lineNumber":116,"sourceCode":"            \"\"\");\n  }\n\n  @Override\n  protected void crawlAccounts(final Flux<Account> accounts) {\n    final long maxQueueSizeBytes = getNamespace().getLong(MAX_QUEUE_SIZE_BYTES_ARGUMENT);\n    final long targetQueueSizeBytes = getNamespace().getLong(TARGET_QUEUE_SIZE_BYTES_ARGUMENT);\n    final long rangeSplitChunkSizeBytes = getNamespace().getLong(RANGE_SPLIT_CHUNK_SIZE_BYTES_ARGUMENT);\n\n    if (targetQueueSizeBytes <= 0) {\n      throw new IllegalArgumentException(\"target-queue-size-bytes must be positive\");\n    }\n\n    if (targetQueueSizeBytes >= maxQueueSizeBytes) {\n      throw new IllegalArgumentException(\"target-queue-size-bytes must be less than max-queue-size-bytes\");\n    }\n\n    if (rangeSplitChunkSizeBytes <= 0) {\n      throw new IllegalArgumentException(\"range-split-chunk-size-bytes must be positive\");\n    }\n\n    final boolean dryRun = getNamespace().getBoolean(DRY_RUN_ARGUMENT);\n    final int maxConcurrency = getNamespace().getInt(MAX_CONCURRENCY_ARGUMENT);\n\n    final MessagesManager messagesManager = getCommandDependencies().messagesManager();\n\n    accounts\n        .flatMapIterable(account ->\n            account.getDevices().stream().map(\n                device -> new Pair<>(new AciServiceIdentifier(account.getAccountIdentifier()), device)).toList())\n        .doOnNext(_ -> Metrics.counter(QUEUES_INSPECTED_COUNTER_NAME, \"dryRun\", String.valueOf(dryRun)).increment())\n        .flatMap(accountAndDevice ->\n            messagesManager.trimQueue(accountAndDevice.first(), accountAndDevice.second(), maxQueueSizeBytes, targetQueueSizeBytes, rangeSplitChunkSizeBytes, dryRun),\n            maxConcurrency)\n        .onErrorResume(e  -> {\n          LOGGER.error(\"Failed to trim queue\", e);\n          return Mono.empty();","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/signalapp/Signal-Server/blob/100ab61c82627582c867d19e1c0561ba2781e927/service/src/main/java/org/whispersystems/textsecuregcm/workers/TrimOversizedFoundationDbMessageQueuesCommand.java#L98-L134","documentation":"range-split-chunk-size-bytes controls the chunk size used to split the account range for parallel crawling; a zero or negative value is invalid, so crawlAccounts throws IllegalArgumentException before doing work.","triggerScenarios":"Running the trim command with --range-split-chunk-size-bytes of 0 or a negative number.","commonSituations":"Placeholder value left in a runbook; a computed/default expression evaluating to 0; misunderstanding that the value is in bytes.","solutions":["Pass a positive byte value, e.g. --range-split-chunk-size-bytes 1000000","Fix the variable/expression that supplied the flag value","Check script ordering so the value is set before the command runs"],"exampleFix":"// before\n--range-split-chunk-size-bytes 0\n// after\n--range-split-chunk-size-bytes 1000000","handlingStrategy":"validation","validationCode":"long chunk = Long.parseLong(args[\"range-split-chunk-size-bytes\"]);\nif (chunk <= 0) throw new IllegalArgumentException(\"range-split-chunk-size-bytes must be positive\");","typeGuard":null,"tryCatchPattern":"try { crawlAccounts(accounts); } catch (IllegalArgumentException e) { System.err.println(\"config: \" + e.getMessage()); System.exit(2); }","preventionTips":["Use a sensible default like 1_000_000 bytes","Confirm computed defaults are non-zero","Keep the command's tuning values in a reviewed config script"],"tags":["cli","validation","configuration"],"backgroundTag":"invalid-argument-value","analyzedSha":"100ab61c82627582c867d19e1c0561ba2781e927","analyzedAt":"2026-09-09T13:29:47.883Z","contentChangedAt":"2026-09-09T13:29:47.883Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}