Case study / beets

Shell completion crashed with one plugin enabled.

One real regression, in a review where most findings were not bugs.

beets is a music library manager with plugins. A review of one of its commits produced a test showing that the titlecase plugin could not hand out its commands twice. A person then found the visible effect: beet completion exits 1 when the plugin is enabled. The fix is open upstream as beetbox/beets#7161. On 2026-11-12 it is open and not merged.

1. Repository and reviewed commit

beetbox/beets, commit 80e970504, which added a shared --limit option to several commands (upstream pull request #7003): 45 files, 254 lines added and 98 removed. The commit was picked by a rule fixed before any run, as part of the experiment described in AI code review findings on unfamiliar repositories. arnx had no earlier contact with the repository.

2. Expected behavior

A plugin's commands() method can be called more than once. beets does so itself: beet completion asks every plugin for its commands a second time to build the completion script. With plugins: titlecase in the configuration, beet completion should exit 0.

3. Actual behavior

beet completion, with plugins: titlecase
optparse.OptionConflictError: option -l/--limit: conflicting option string(s): -l, --limit

The command exits 1. Without the plugin it exits 0.

4. Suspected defect

Before any test ran, the second hunter (gpt-6.1-sol) suspected: Titlecase command discovery fails when called more than once on the same plugin instance. TitlecasePlugin.commands() added the limit option to a parser that is built once, in __init__. A second call added the same option again.

5. Generated test

The reviewer wrote test_titlecase_commands_idempotent in tests/arnx_generated/test_limit_option.py: create the plugin, call commands() twice, and expect no error.

6. Execution result

From review.md, quoted
### F8 · regression · confirmed by the second opinion
- Test: `tests/arnx_generated/test_limit_option.py::test_titlecase_commands_idempotent`
- Failure:
  `optparse.OptionConflictError: option -l/--limit: conflicting option string(s): -l, --limit`
- Reviewer: `TitlecasePlugin.commands()` calls `add_limit_option()` on a parser created
  once in `__init__`. A second call raises `optparse.OptionConflictError`, so rebuilding
  the CLI in the same process breaks.
- Before the change (regression): passes on the code before the change (3 runs): the
  change broke it

The review ran 55 tests in 13 minutes 39 seconds for $0.96. Reviewer: claude-sonnet-5-5. Second opinion: GLM-5.3-Flash through River. These numbers come from our local review record, not from a public page.

7. Correction

The fix adds the option in __init__, right after the command is created, and removes the call from commands(). Other beets plugins that share the option already add it there. The pull request changes three files: the plugin, the changelog and the plugin's tests. Claude wrote the fix. The owner of arnx reproduced the crash, tested and reviewed the change, and opened the pull request with the AI disclosure that beets' AI policy asks for.

The regression test in the pull request
def test_commands_can_be_requested_twice(self):
    """``beet completion`` asks every plugin for its commands again."""
    plugin = TitlecasePlugin()
    assert plugin.commands() == plugin.commands()

8. Verification result

From the pull request: the new test fails without the fix with the error above. beet completion with the plugin enabled exits 1 before the fix and 0 after. beet titlecase --help still lists --limit. The full suite on Python 3.11 reported 2,817 passed and 182 skipped. The pull request also says its own test_completion was skipped, because the test image had no bash-completion package.

On GitHub on 2026-11-12: one approving review, checks passing, state open, a further review still required. It is not merged.

9. Upstream references

10. Limitations and observations

Last reviewed 2026-11-12 against arnx 0.1.11. The release documentation is canonical for your installed version.