BUG-HUNT: [error-handling] Unhelpful error message in find_fixture #2832

Open
opened 2026-04-04 20:44:20 +00:00 by freemo · 0 comments
Owner

Metadata

  • Branch: fix/error-handling-find-fixture-unhelpful-error-message
  • Commit Message: fix(error-handling): include available fixture names in find_fixture ValueError message
  • Milestone: v3.7.0
  • Parent Epic: #362

Description

The find_fixture function in features/fixtures/validation/suite_helpers.py raises a ValueError when a fixture is not found, but the error message only says "Fixture '{name}' not found". This is unhelpful when debugging tests because the user cannot see what fixtures are actually available. The error message should include the list of available fixture names so the user can quickly identify misspellings or incorrect fixture references.

Location

  • File: features/fixtures/validation/suite_helpers.py
  • Function/Class: find_fixture
  • Lines: 84–87

Evidence

def find_fixture(fixtures: list[dict[str, Any]], name: str) -> dict[str, Any]:
    """Find a fixture by name in a fixture list.

    Raises ``ValueError`` if not found.
    """
    for f in fixtures:
        if f["name"] == name:
            return f
    msg = f"Fixture '{name}' not found"
    raise ValueError(msg)

Expected Behavior

The error message should include the list of available fixture names so the user can see what options are available.

Actual Behavior

The error message only states that the fixture was not found, with no indication of what fixtures are available.

Suggested Fix

def find_fixture(fixtures: list[dict[str, Any]], name: str) -> dict[str, Any]:
    """Find a fixture by name in a fixture list.

    Raises ``ValueError`` if not found.
    """
    for f in fixtures:
        if f["name"] == name:
            return f
    available_fixtures = [f['name'] for f in fixtures]
    msg = f"Fixture '{name}' not found. Available fixtures: {available_fixtures}"
    raise ValueError(msg)

Severity Assessment

  • Impact: Minor inconvenience when debugging tests.
  • Likelihood: High, whenever a fixture name is misspelled or incorrect.
  • Priority: Low

Subtasks

  • Update find_fixture in features/fixtures/validation/suite_helpers.py to include available fixture names in the ValueError message
  • Update or add unit tests to assert the new error message format includes available fixture names

Definition of Done

  • find_fixture raises ValueError with a message listing all available fixture names when the requested fixture is not found
  • Existing tests updated to match the new error message format
  • New unit test added asserting the available fixtures are listed in the error message
  • All nox stages pass
  • Coverage >= 97%

Automated by CleverAgents Bot
Supervisor: Bug Hunting | Agent: ca-new-issue-creator

## Metadata - **Branch**: `fix/error-handling-find-fixture-unhelpful-error-message` - **Commit Message**: `fix(error-handling): include available fixture names in find_fixture ValueError message` - **Milestone**: v3.7.0 - **Parent Epic**: #362 ## Description The `find_fixture` function in `features/fixtures/validation/suite_helpers.py` raises a `ValueError` when a fixture is not found, but the error message only says `"Fixture '{name}' not found"`. This is unhelpful when debugging tests because the user cannot see what fixtures are actually available. The error message should include the list of available fixture names so the user can quickly identify misspellings or incorrect fixture references. ### Location - **File**: `features/fixtures/validation/suite_helpers.py` - **Function/Class**: `find_fixture` - **Lines**: 84–87 ### Evidence ```python def find_fixture(fixtures: list[dict[str, Any]], name: str) -> dict[str, Any]: """Find a fixture by name in a fixture list. Raises ``ValueError`` if not found. """ for f in fixtures: if f["name"] == name: return f msg = f"Fixture '{name}' not found" raise ValueError(msg) ``` ### Expected Behavior The error message should include the list of available fixture names so the user can see what options are available. ### Actual Behavior The error message only states that the fixture was not found, with no indication of what fixtures are available. ### Suggested Fix ```python def find_fixture(fixtures: list[dict[str, Any]], name: str) -> dict[str, Any]: """Find a fixture by name in a fixture list. Raises ``ValueError`` if not found. """ for f in fixtures: if f["name"] == name: return f available_fixtures = [f['name'] for f in fixtures] msg = f"Fixture '{name}' not found. Available fixtures: {available_fixtures}" raise ValueError(msg) ``` ### Severity Assessment - **Impact**: Minor inconvenience when debugging tests. - **Likelihood**: High, whenever a fixture name is misspelled or incorrect. - **Priority**: Low ## Subtasks - [ ] Update `find_fixture` in `features/fixtures/validation/suite_helpers.py` to include available fixture names in the `ValueError` message - [ ] Update or add unit tests to assert the new error message format includes available fixture names ## Definition of Done - [ ] `find_fixture` raises `ValueError` with a message listing all available fixture names when the requested fixture is not found - [ ] Existing tests updated to match the new error message format - [ ] New unit test added asserting the available fixtures are listed in the error message - [ ] All nox stages pass - [ ] Coverage >= 97% --- **Automated by CleverAgents Bot** Supervisor: Bug Hunting | Agent: ca-new-issue-creator
freemo added this to the v3.7.0 milestone 2026-04-04 20:44:25 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Blocks
#362 Epic: Security & Safety Hardening
cleveragents/cleveragents-core
Reference
cleveragents/cleveragents-core#2832
No description provided.