Unhandled ValueError in reference_parser.py #8872

Open
opened 2026-04-14 03:07:48 +00:00 by HAL9000 · 1 comment
Owner

Metadata

  • Commit Message: fix(tui): handle ValueError for malformed reference strings in parse_references
  • Branch Name: bugfix/v3.7.0-reference-parser-valueerror

Background and Context

The parse_references function in src/cleveragents/tui/input/reference_parser.py does not handle a ValueError that can occur when splitting a malformed reference string. When a user types a token such as "@:" in the TUI input box, the function attempts to unpack the result of raw.split(":", 1) into two variables. If the string is malformed and the split does not produce the expected two parts, a ValueError is raised and propagates unhandled, crashing the TUI.

Code evidence:

# src/cleveragents/tui/input/reference_parser.py:123
category, rest = raw.split(":", 1)

This issue belongs to the Reference and Command Input System (Epic #8604), which is part of the v3.7.0 TUI Implementation milestone.

Expected Behavior

When parse_references receives a malformed reference token (e.g., "@:"), the function should handle the ValueError gracefully — for example, by treating the token as an unresolved reference and continuing without crashing the TUI.

Acceptance Criteria

  • parse_references("@:") does not raise an unhandled ValueError
  • Malformed reference tokens are treated as unresolved (e.g., returned as-is or skipped)
  • No regression in existing reference parsing behaviour for well-formed tokens
  • Unit tests cover the malformed input path ("@:", "@", "@::", etc.)
  • Test coverage for reference_parser.py remains ≥ 97%

Subtasks

  • Wrap the raw.split(":", 1) unpacking in a try/except ValueError block in parse_references
  • Return the token as unresolved (or skip it) when a ValueError is caught
  • Add a unit test scenario for parse_references("@:") asserting graceful handling
  • Add unit test scenarios for other malformed tokens ("@", "@::", empty string after @)
  • Verify no regression against existing passing tests

Definition of Done

This issue should be closed when:

  1. All acceptance criteria above are verified and checked off
  2. The fix is merged to the main branch and CI passes
  3. Test coverage for reference_parser.py is confirmed ≥ 97%
  4. The parent Epic #8604 subtask list is updated to reflect this fix

Automated by CleverAgents Bot
Agent: new-issue-creator

## Metadata - **Commit Message**: `fix(tui): handle ValueError for malformed reference strings in parse_references` - **Branch Name**: `bugfix/v3.7.0-reference-parser-valueerror` ## Background and Context The `parse_references` function in `src/cleveragents/tui/input/reference_parser.py` does not handle a `ValueError` that can occur when splitting a malformed reference string. When a user types a token such as `"@:"` in the TUI input box, the function attempts to unpack the result of `raw.split(":", 1)` into two variables. If the string is malformed and the split does not produce the expected two parts, a `ValueError` is raised and propagates unhandled, crashing the TUI. **Code evidence:** ```python # src/cleveragents/tui/input/reference_parser.py:123 category, rest = raw.split(":", 1) ``` This issue belongs to the Reference and Command Input System (Epic #8604), which is part of the v3.7.0 TUI Implementation milestone. ## Expected Behavior When `parse_references` receives a malformed reference token (e.g., `"@:"`), the function should handle the `ValueError` gracefully — for example, by treating the token as an unresolved reference and continuing without crashing the TUI. ## Acceptance Criteria - [ ] `parse_references("@:")` does not raise an unhandled `ValueError` - [ ] Malformed reference tokens are treated as unresolved (e.g., returned as-is or skipped) - [ ] No regression in existing reference parsing behaviour for well-formed tokens - [ ] Unit tests cover the malformed input path (`"@:"`, `"@"`, `"@::"`, etc.) - [ ] Test coverage for `reference_parser.py` remains ≥ 97% ## Subtasks - [ ] Wrap the `raw.split(":", 1)` unpacking in a `try/except ValueError` block in `parse_references` - [ ] Return the token as unresolved (or skip it) when a `ValueError` is caught - [ ] Add a unit test scenario for `parse_references("@:")` asserting graceful handling - [ ] Add unit test scenarios for other malformed tokens (`"@"`, `"@::"`, empty string after `@`) - [ ] Verify no regression against existing passing tests ## Definition of Done This issue should be closed when: 1. All acceptance criteria above are verified and checked off 2. The fix is merged to the main branch and CI passes 3. Test coverage for `reference_parser.py` is confirmed ≥ 97% 4. The parent Epic #8604 subtask list is updated to reflect this fix --- **Automated by CleverAgents Bot** Agent: new-issue-creator
HAL9000 added this to the v3.7.0 milestone 2026-04-14 03:11:10 +00:00
Author
Owner

Triage Decision: VERIFIED — MoSCoW/Must Have

Real TUI bug: parse_references in reference_parser.py raises an unhandled ValueError when a malformed reference token like "@:" is entered. This crashes the TUI, which is unacceptable for a user-facing feature.

Priority/High — TUI crashes on malformed input are a reliability issue.


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

✅ **Triage Decision: VERIFIED — MoSCoW/Must Have** Real TUI bug: `parse_references` in `reference_parser.py` raises an unhandled `ValueError` when a malformed reference token like `"@:"` is entered. This crashes the TUI, which is unacceptable for a user-facing feature. **Priority/High** — TUI crashes on malformed input are a reliability issue. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: project-owner-pool-supervisor
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.

Dependencies

No dependencies set.

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