What's happening
Transactions.reverse() (actionkit/transactions.py:48-57):
except ValidationError as e:
# Since the underlying http code can now raise a ValidationError, we need to catch it
# here in case it's flagging an already reversed transaction
order_id_message = e.errors
if order_id_message == 'Transaction has already been reversed.':
self.connection.logger.warning(...)
else:
raise e
ValidationError.errors (actionkit/validation.py:30) is list(response.values()) — a list, not a string. Comparing a list to the string literal 'Transaction has already been reversed.' can never be True, so this branch's "swallow an already-reversed error" behavior never actually fires — it always falls through to raise e.
This looks like it was meant to check a specific field, the way the sibling except HTTPError branch above it does:
error_json = e.response.json()
order_id_message = error_json.get('order_id', None)
if order_id_message == 'Transaction has already been reversed.':
i.e. probably meant e['order_id'] (using ValidationError.__getitem__, which returns [] for a missing key) rather than e.errors.
Relationship to #15
This branch exists specifically because of the systemic finding in #15 (real ActionKit error bodies get converted to ValidationError, not HTTPError) — it's the intended real-world handler for the "already reversed" case, but it's broken independently of that issue.
Suggested fix
except ValidationError as e:
if e['order_id'] == ['Transaction has already been reversed.']:
self.connection.logger.warning(...)
else:
raise e
(exact expected shape of e['order_id'] — string vs. list — should be confirmed against a real ActionKit error response before fixing.)
Test coverage
Pinned (not fixed) by tests/test_transactions.py::test_reverse_validation_error_already_reversed_branch_is_dead.
What's happening
Transactions.reverse()(actionkit/transactions.py:48-57):ValidationError.errors(actionkit/validation.py:30) islist(response.values())— a list, not a string. Comparing a list to the string literal'Transaction has already been reversed.'can never beTrue, so this branch's "swallow an already-reversed error" behavior never actually fires — it always falls through toraise e.This looks like it was meant to check a specific field, the way the sibling
except HTTPErrorbranch above it does:i.e. probably meant
e['order_id'](usingValidationError.__getitem__, which returns[]for a missing key) rather thane.errors.Relationship to #15
This branch exists specifically because of the systemic finding in #15 (real ActionKit error bodies get converted to
ValidationError, notHTTPError) — it's the intended real-world handler for the "already reversed" case, but it's broken independently of that issue.Suggested fix
(exact expected shape of
e['order_id']— string vs. list — should be confirmed against a real ActionKit error response before fixing.)Test coverage
Pinned (not fixed) by
tests/test_transactions.py::test_reverse_validation_error_already_reversed_branch_is_dead.