{"record":{"id":"752c9a72c148c4b9","repo":"grosser/parallel_tests","slug":"group-by-allowed-join-or-is-required-for","errorCode":null,"errorMessage":"--group-by #{allowed.join(\" or \")} is required for --only-group","messagePattern":"--group-by #(.+?) is required for --only-group","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"lib/parallel_tests/cli.rb","lineNumber":376,"sourceCode":"          if File.directory?(default_test_folder)\n            files = [default_test_folder]\n          else\n            abort \"Pass files or folders to run\"\n          end\n        end\n        options[:files] = files.map { |file_path| Pathname.new(file_path).cleanpath.to_s }\n      end\n\n      append_test_options(options, remaining)\n\n      options[:group_by] ||= :filesize if options[:only_group]\n\n      if options[:group_by] == :found && options[:single_process]\n        raise \"--group-by found and --single-process are not supported\"\n      end\n      allowed = [:filesize, :runtime, :found]\n      if !allowed.include?(options[:group_by]) && options[:only_group]\n        raise \"--group-by #{allowed.join(\" or \")} is required for --only-group\"\n      end\n\n      if options[:specify_groups] && options.keys.intersect?([:single_process, :isolate, :isolate_count])\n        raise \"Can't pass --specify-groups with any of these keys: --single, --isolate, or --isolate-n\"\n      end\n\n      if options[:failure_exit_code] && options[:highest_exit_status]\n        raise \"Can't pass --failure-exit-code and --highest-exit-status\"\n      end\n\n      options\n    end\n\n    def extract_file_paths(argv)\n      dash_index = argv.rindex(\"--\")\n      file_args_at = (dash_index || -1) + 1\n      [argv[file_args_at..], argv[0...(dash_index || 0)]]\n    end","sourceCodeStart":358,"sourceCodeEnd":394,"githubUrl":"https://github.com/grosser/parallel_tests/blob/a06047856d3564ee77848e230d61cb6503037ad7/lib/parallel_tests/cli.rb#L358-L394","documentation":"--only-group re-runs a subset of previously computed groups, which only stays correct for deterministic grouping strategies. The CLI restricts the combination to filesize, runtime and found; note that when --only-group is given without --group-by, filesize is assumed (cli.rb:369), so this raise fires only when an explicitly incompatible value such as steps, scenarios or default is passed.","triggerScenarios":"`parallel_test --group-by steps --only-group 1`; `--group-by scenarios --only-group 2,3`; any explicit --group-by value outside [:filesize, :runtime, :found] combined with --only-group, via CLI flags or a rake PARALLEL_TEST_OPTS string.","commonSituations":"Cucumber suites that use step-count grouping add --only-group to re-run a failed group on CI; job templates copy a --group-by from one CI job into another that already carried --only-group; debugging sessions temporarily set group_by to 'default' and leave it behind.","solutions":["Remove the explicit --group-by -- with --only-group it defaults to filesize, which is deterministic and allowed","Or set --group-by to runtime (with a populated runtime log) or found","If steps/scenarios grouping is required, drop --only-group and select the files directly instead of group indexes"],"exampleFix":"# before\nparallel_test -t cucumber --group-by steps --only-group 1\n\n# after\nparallel_test -t cucumber --only-group 1 # defaults to --group-by filesize","handlingStrategy":"validation","validationCode":"ALLOWED_GROUP_BY = %w[filesize runtime found].freeze\nopts = ENV.fetch('PARALLEL_TEST_OPTS', '').shellsplit\nif (i = opts.index('--group-by')) && opts[i + 1] && !ALLOWED_GROUP_BY.include?(opts[i + 1]) && opts.include?('--only-group')\n  abort \"parallel_tests: --only-group needs --group-by #{ALLOWED_GROUP_BY.join(' or ')}\"\nend","typeGuard":"def only_group_compatible?(group_by)\n  %w[filesize runtime found].include?(group_by)\nend","tryCatchPattern":"begin\n  ParallelTests::CLI.new.run(args)\nrescue RuntimeError => e\n  abort \"#{e.message} -- omit --group-by (defaults to filesize) or use filesize/runtime/found\"\nend","preventionTips":["Omit --group-by when using --only-group so the deterministic filesize default applies","Encode the allowed grouping values in a wrapper/rake task constant","Document next to each CI job why its grouping strategy was chosen, so flags do not get mixed between jobs"],"tags":["ruby","parallel-tests","cli","grouping","option-validation"],"backgroundTag":"invalid-option-combination","analyzedSha":"a06047856d3564ee77848e230d61cb6503037ad7","analyzedAt":"2026-08-23T10:12:36.391Z","schemaVersion":2},"datasetVersion":"2026-08-23T13:39:53.451Z"}