BUG-HUNT: [boundary] Empty string in supported_extensions not handled in AnalyzerRegistry #1851

Open
opened 2026-04-02 23:58:48 +00:00 by freemo · 2 comments
Owner

Metadata

  • Branch: fix/analyzer-registry-empty-extension-validation
  • Commit Message: fix(acms): raise ValueError for empty string in AnalyzerRegistry.register supported_extensions
  • Milestone: v3.7.0
  • Parent Epic: #935

Background and Context

The AnalyzerRegistry.register method in src/cleveragents/domain/models/acms/analyzers.py validates that each extension in an analyzer's supported_extensions set starts with a leading dot. However, it does not guard against an empty string ("") being present in that set. Per the project's fail-fast and argument-validation principles (CONTRIBUTING.md §Error and Exception Handling), all public methods must validate arguments at the boundary and reject invalid inputs immediately.

An empty string would pass the not ext.startswith(".") check (since "".startswith(".") is False, the guard would raise — wait, actually "".startswith(".") returns False, so the existing guard would raise a ValueError for the wrong reason: "Extension '' must start with a leading dot"). However, the error message would be misleading and the intent is not clear. More importantly, the correct, explicit guard for an empty string is missing, making the code's intent ambiguous and the error message unhelpful.

Current Behavior

If an analyzer's supported_extensions set contains an empty string "", the existing startswith(".") check raises a ValueError with a misleading message: "Extension '' must start with a leading dot (e.g. '.py')". There is no explicit, dedicated guard for the empty-string case.

Expected Behavior

The register method should explicitly check for and reject empty strings before the leading-dot check, raising a clear ValueError such as:
"Extension must not be an empty string, got from <AnalyzerName>".

Acceptance Criteria

  • AnalyzerRegistry.register raises ValueError with a clear message when supported_extensions contains an empty string "".
  • The empty-string check occurs before the leading-dot check.
  • A BDD scenario covers this boundary case (empty string in supported_extensions).
  • All existing tests continue to pass.

Supporting Information

  • File: src/cleveragents/domain/models/acms/analyzers.py
  • Class/Method: AnalyzerRegistry.register (lines 180–237)
  • Severity: Low — unlikely in practice, but violates the fail-fast and explicit-validation principles.
  • Reported by: ca-bug-hunter (Bug Hunting supervisor)

Evidence

for ext in extensions:
    if not ext.startswith("."):
        raise ValueError(
            f"Extension '{ext}' must start with a leading dot "
            f"(e.g. '.py'), got from {type(analyzer).__name__}"
        )

Suggested Fix

for ext in extensions:
    if not ext:
        raise ValueError(
            f"Extension must not be an empty string, "
            f"got from {type(analyzer).__name__}"
        )
    if not ext.startswith("."):
        raise ValueError(
            f"Extension '{ext}' must start with a leading dot "
            f"(e.g. '.py'), got from {type(analyzer).__name__}"
        )

Subtasks

  • Add explicit empty-string guard in AnalyzerRegistry.register before the leading-dot check
  • Write BDD scenario: Given an analyzer with an empty string in supported_extensions, When registered, Then a ValueError is raised with a clear message
  • Verify coverage >= 97% via nox -s coverage_report
  • Run nox (all default sessions), fix any errors

Definition of Done

This issue is complete when:

  • All subtasks above are completed and checked off.
  • A Git commit is created where the first line of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation.
  • The commit is pushed to the remote on the branch matching the Branch in Metadata exactly.
  • The commit is submitted as a pull request to master, reviewed, and merged before this issue is marked done.
  • All nox stages pass.
  • Coverage >= 97%.

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

## Metadata - **Branch**: `fix/analyzer-registry-empty-extension-validation` - **Commit Message**: `fix(acms): raise ValueError for empty string in AnalyzerRegistry.register supported_extensions` - **Milestone**: v3.7.0 - **Parent Epic**: #935 ## Background and Context The `AnalyzerRegistry.register` method in `src/cleveragents/domain/models/acms/analyzers.py` validates that each extension in an analyzer's `supported_extensions` set starts with a leading dot. However, it does not guard against an empty string (`""`) being present in that set. Per the project's fail-fast and argument-validation principles (CONTRIBUTING.md §Error and Exception Handling), all public methods must validate arguments at the boundary and reject invalid inputs immediately. An empty string would pass the `not ext.startswith(".")` check (since `"".startswith(".")` is `False`, the guard would raise — wait, actually `"".startswith(".")` returns `False`, so the existing guard **would** raise a `ValueError` for the wrong reason: "Extension '' must start with a leading dot"). However, the error message would be misleading and the intent is not clear. More importantly, the correct, explicit guard for an empty string is missing, making the code's intent ambiguous and the error message unhelpful. ## Current Behavior If an analyzer's `supported_extensions` set contains an empty string `""`, the existing `startswith(".")` check raises a `ValueError` with a misleading message: `"Extension '' must start with a leading dot (e.g. '.py')"`. There is no explicit, dedicated guard for the empty-string case. ## Expected Behavior The `register` method should explicitly check for and reject empty strings before the leading-dot check, raising a clear `ValueError` such as: `"Extension must not be an empty string, got from <AnalyzerName>"`. ## Acceptance Criteria - [ ] `AnalyzerRegistry.register` raises `ValueError` with a clear message when `supported_extensions` contains an empty string `""`. - [ ] The empty-string check occurs **before** the leading-dot check. - [ ] A BDD scenario covers this boundary case (empty string in `supported_extensions`). - [ ] All existing tests continue to pass. ## Supporting Information - **File**: `src/cleveragents/domain/models/acms/analyzers.py` - **Class/Method**: `AnalyzerRegistry.register` (lines 180–237) - **Severity**: Low — unlikely in practice, but violates the fail-fast and explicit-validation principles. - **Reported by**: ca-bug-hunter (Bug Hunting supervisor) ### Evidence ```python for ext in extensions: if not ext.startswith("."): raise ValueError( f"Extension '{ext}' must start with a leading dot " f"(e.g. '.py'), got from {type(analyzer).__name__}" ) ``` ### Suggested Fix ```python for ext in extensions: if not ext: raise ValueError( f"Extension must not be an empty string, " f"got from {type(analyzer).__name__}" ) if not ext.startswith("."): raise ValueError( f"Extension '{ext}' must start with a leading dot " f"(e.g. '.py'), got from {type(analyzer).__name__}" ) ``` ## Subtasks - [ ] Add explicit empty-string guard in `AnalyzerRegistry.register` before the leading-dot check - [ ] Write BDD scenario: `Given an analyzer with an empty string in supported_extensions, When registered, Then a ValueError is raised with a clear message` - [ ] Verify coverage >= 97% via `nox -s coverage_report` - [ ] Run `nox` (all default sessions), fix any errors ## Definition of Done This issue is complete when: - All subtasks above are completed and checked off. - A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation. - The commit is pushed to the remote on the branch matching the **Branch** in Metadata exactly. - The commit is submitted as a **pull request** to `master`, reviewed, and **merged** before this issue is marked done. - 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-02 23:59:59 +00:00
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • MoSCoW: MoSCoW/Should Have — bug or error handling improvement.

Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: ca-project-owner

Issue triaged by project owner: - **State**: Verified - **MoSCoW**: MoSCoW/Should Have — bug or error handling improvement. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: ca-project-owner
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • MoSCoW: MoSCoW/Should Have — bug or error handling improvement.

Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: ca-project-owner

Issue triaged by project owner: - **State**: Verified - **MoSCoW**: MoSCoW/Should Have — bug or error handling improvement. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: ca-project-owner
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.

Reference
cleveragents/cleveragents-core#1851
No description provided.