Make a partly-undone import retryable, and refuse a plan it cannot deliver
This commit is contained in:
@@ -701,6 +701,7 @@ def winc_import_batches():
|
||||
def winc_import_undo():
|
||||
"""Reverse an applied WINC import batch by id. Conservative and reversible."""
|
||||
from shopdb.core.services.wincimport import undo as winc_undo
|
||||
from shopdb.core.services.wincimport import WincImportError
|
||||
|
||||
payload = request.get_json(silent=True) or {}
|
||||
batchid = (payload.get('batchid') or request.form.get('batchid') or '').strip()
|
||||
@@ -714,7 +715,10 @@ def winc_import_undo():
|
||||
changes={'batchid': batchid, 'reverted': result['reverted'],
|
||||
'conflicts': len(result['conflicts'])})
|
||||
db.session.commit()
|
||||
except ValueError as exc:
|
||||
except (ValueError, WincImportError) as exc:
|
||||
# WincImportError too: refusing a batch of another importer's kind is a
|
||||
# bad request, not a server fault. Preview and commit already catch it;
|
||||
# this route did not, so the refusal surfaced as a 500.
|
||||
db.session.rollback()
|
||||
return error_response(ErrorCodes.VALIDATION_ERROR, str(exc))
|
||||
except Exception:
|
||||
|
||||
Reference in New Issue
Block a user