View Issue Details

IDProjectCategoryView StatusLast Update
0005889Talerbank (demonstrator)public2019-09-16 21:21
ReporterMarcello StanisciAssigned ToMarcello Stanisci 
PrioritynormalSeveritycrashReproducibilityhave not tried
Status feedbackResolutionopen 
Product Version 
Target VersionFixed in Version 
Summary0005889: Reject logic crashes for across-the-zero reimbursements.
DescriptionSay account A gave 10 KUDOS to account B with transaction T, and at some point B rejects transaction T *but* has only 4 KUDOS left on their account. The operation is legitimate if the bank allows their account to reach - for example - 10 KUDOS debit.

Nonetheless, the current logic would not accomplish this operation because it will try to subtract 10 KUDOS (T's amount) from 4 KUDOS (B's balance), and raise (unhandled) ValueError!

The solution would be for the subtraction to go debit until the allowed threshold, and only raise exception if this limit is surpassed.
Additional InformationSome logs.

Sep 10 23:40:12-997764 test-bank-api-with-(fake)bank-new-8179 DEBUG Running command `reject-1'
Sep 10 23:40:12-997785 test-bank-api-with-(fake)bank-new-8179 INFO Account 2 rejects deposit
Internal Server Error: /reject
Traceback (most recent call last):
  File "/home/marcello/.local/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/home/marcello/.local/lib/python3.7/site-packages/django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/home/marcello/.local/lib/python3.7/site-packages/django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/lib/python3.7/contextlib.py", line 74, in inner
    return func(*args, **kwds)
  File "/home/marcello/.local/lib/python3.7/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
    return view_func(*args, **kwargs)
  File "/home/marcello/.local/lib/python3.7/site-packages/django/views/decorators/http.py", line 40, in inner
    return func(request, *args, **kwargs)
  File "/home/marcello/.local/lib/python3.7/site-packages/talerbank/app/views.py", line 561, in _decorator
    return view_func(request, user_account, *args, **kwargs)
  File "/home/marcello/.local/lib/python3.7/site-packages/talerbank/app/views.py", line 807, in reject
    trans.credit_account.amount.subtract(trans.amount)
  File "/home/marcello/.local/lib/python3.7/site-packages/talerbank/app/amount.py", line 224, in subtract
    raise ValueError('self is lesser than amount to be subtracted')
ValueError: self is lesser than amount to be subtracted
2019-09-10 21:40:13,155 log ERROR Internal Server Error: /reject
Traceback (most recent call last):
  File "/home/marcello/.local/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/home/marcello/.local/lib/python3.7/site-packages/django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/home/marcello/.local/lib/python3.7/site-packages/django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/lib/python3.7/contextlib.py", line 74, in inner
    return func(*args, **kwds)
  File "/home/marcello/.local/lib/python3.7/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
    return view_func(*args, **kwargs)
  File "/home/marcello/.local/lib/python3.7/site-packages/django/views/decorators/http.py", line 40, in inner
    return func(request, *args, **kwargs)
  File "/home/marcello/.local/lib/python3.7/site-packages/talerbank/app/views.py", line 561, in _decorator
    return view_func(request, user_account, *args, **kwargs)
  File "/home/marcello/.local/lib/python3.7/site-packages/talerbank/app/views.py", line 807, in reject
    trans.credit_account.amount.subtract(trans.amount)
  File "/home/marcello/.local/lib/python3.7/site-packages/talerbank/app/amount.py", line 224, in subtract
    raise ValueError('self is lesser than amount to be subtracted')
ValueError: self is lesser than amount to be subtracted
10/Sep/2019:21:40:12 +0000 HTTP/1.1 POST /reject HTTP/1.1 => 500
TagsNo tags attached.

Activities

Christian Grothoff

2019-09-16 21:20

manager   ~0014907

First of all, I think in the case of a transaction being cancelled, it is OK if the usual account limits are being violated. So that check is not required.

c540308..4043cac should fix the crash itself, by properly handling negative balances. All tests still pass. However, as there is no way to 'reject' transactions in the Web interface, I did not test the actual logic in question. But it's pretty simple. Still, if you have an easy way to reproduce it, please give it a spin.

Issue History

Date Modified Username Field Change
2019-09-11 00:05 Marcello Stanisci New Issue
2019-09-11 00:05 Marcello Stanisci Status new => assigned
2019-09-11 00:05 Marcello Stanisci Assigned To => Marcello Stanisci
2019-09-11 00:06 Marcello Stanisci Description Updated View Revisions
2019-09-11 00:07 Marcello Stanisci Additional Information Updated View Revisions
2019-09-11 00:07 Marcello Stanisci Assigned To Marcello Stanisci =>
2019-09-16 09:27 Christian Grothoff Assigned To => Marcello Stanisci
2019-09-16 09:27 Christian Grothoff Assigned To Marcello Stanisci => Christian Grothoff
2019-09-16 09:29 Christian Grothoff Severity minor => crash
2019-09-16 21:20 Christian Grothoff Note Added: 0014907
2019-09-16 21:21 Christian Grothoff Assigned To Christian Grothoff => Marcello Stanisci
2019-09-16 21:21 Christian Grothoff Status assigned => feedback