Skip to content

[low] _resolve_backend invalid-input branches (bad string / bad type) are untested #54

@toloco

Description

@toloco

Severity: ⚪ low • Category: untested-path
Location: warp_cache/_decorator.py : 121-132

What's wrong

_resolve_backend raises ValueError for an unknown backend string and TypeError for a non-Backend/int/str argument. test_shared_basic only covers the happy 'memory'/'shared'/default routing. The error branches (e.g. backend='disk' -> ValueError, backend=1.5 -> TypeError) have no test, so a refactor that swallows the error or maps to the wrong default would not be caught.

Suggested fix

Add with pytest.raises(ValueError): cache(backend='disk') and with pytest.raises(TypeError): cache(backend=1.5), and a positive test that cache(backend=1) (int) resolves to the shared backend.

Adversarial verification note

Verified the cited code at warp_cache/_decorator.py:121-132. _resolve_backend raises ValueError on an unknown backend string (line 131) and TypeError on a non-Backend/int/str argument (line 132), exactly as described. I searched all of tests/ (grep + read of test_strategies.py and test_shared_basic.py routing test). No test passes backend='disk' or any unknown string (no pytest.raises(ValueError)), no test passes a non-int/str/Backend type like 1.5 (no pytest.raises(TypeError)), and no test passes an int like backend=1 to confirm it resolves to SHARED. The only routing coverage is the happy path: default (memory), backend='shared', and string-keyed dispatch via @cache(backend='shared'). So both error branches and the int path are genuinely untested. The finding is a correct untested-path observation, not a code defect; severity low is appropriate.


Filed from a multi-agent code review (finder → adversarial verification → synthesis). Confirmed real after a skeptic re-read the code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    from-reviewFiled from the multi-agent code reviewseverity:lowMinor issue or nituntestedMissing test coverage

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions