fix(core): return True when image-strip retry succeeds in strip_all_images_from_session#591
fix(core): return True when image-strip retry succeeds in strip_all_images_from_session#591Rome-1 wants to merge 1 commit into
Conversation
…_images_from_session The unconditional re-raise after the suppressed retry meant a successful retry still signalled failure (recovery in _run_cycle was discarded) and a double failure swallowed the genuine second error behind the suppressed original. Retry directly so a successful retry falls through to return True and a failed retry propagates the real second exception.
Greptile SummaryThis PR fixes a logic inversion in the
Confidence Score: 5/5Safe to merge — the change is minimal, directly targeted at a well-described logical inversion, and is covered by new tests that exercise both the success and double-failure paths. The old suppress/raise dance meant a successful retry threw away a correctly-rebuilt session; the new code correctly falls through to No files require special attention. Important Files Changed
Reviews (1): Last reviewed commit: "fix(sessions): return True when add_item..." | Re-trigger Greptile |
What & why
strip_all_images_from_sessionis the recovery path invoked by_run_cycle(strix/core/execution.py) when the model rejects image input (HTTP 400/404/422): it rebuilds the session with images swapped for placeholders and re-adds the items. The retry block re-added the items insidecontextlib.suppress(Exception)and then unconditionallyraised, which produced two bad outcomes:stripped = False, and threw away a session that had actually been rebuilt correctly — the scan never retried.This change drops the suppress/raise dance: the first attempt runs, and on failure a single retry runs outside any suppression. A successful retry now falls through to
return Trueso recovery proceeds; a failed retry propagates the genuine second exception. Behaviour on the first-attempt-success path is unchanged.Testing
pytest tests/test_sessions.py— 2 passed. The new tests script a session whoseadd_itemsfails once then succeeds (assertsTrueis returned andadd_itemswas called twice) and one that fails twice (asserts the second exception propagates). Both tests fail against the currentmainimplementation and pass with this change.ruff check/ruff format --check— clean (the repo enables theUP/pyupgrade andS/bandit rule sets; the intentional broad-exceptretry carries a scoped# noqa: BLE001).bandit— no findings;pyupgrade --py310-plus— no changes.mainas well, so this PR makes no mypy claim.