View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0005889 | Taler | py bank (demonstrator, obsolete) | public | 2019-09-11 00:05 | 2021-08-24 16:23 |
Reporter | Marcello Stanisci | Assigned To | Florian Dold | ||
Priority | normal | Severity | crash | Reproducibility | have not tried |
Status | closed | Resolution | fixed | ||
Target Version | 0.8 | Fixed in Version | 0.8 | ||
Summary | 0005889: Reject logic crashes for across-the-zero reimbursements. | ||||
Description | Say 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 Information | Some 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 | ||||
Tags | No tags attached. | ||||
|
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. |
|
We're not using rejections anymore, so the problem doesn't apply anymore. Furthermore, the taler-integrationtests harness now has a test for amount zero crossing. |
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 | |
2019-09-11 00:07 | Marcello Stanisci | Additional Information Updated | |
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 |
2020-08-20 10:31 | Florian Dold | Assigned To | Marcello Stanisci => Florian Dold |
2020-08-20 10:32 | Florian Dold | Status | feedback => resolved |
2020-08-20 10:32 | Florian Dold | Resolution | open => fixed |
2020-08-20 10:32 | Florian Dold | Note Added: 0016670 | |
2020-10-03 14:09 | Christian Grothoff | Fixed in Version | => 0.8 |
2020-10-03 14:10 | Christian Grothoff | Target Version | => 0.8 |
2021-08-24 16:23 | Christian Grothoff | Status | resolved => closed |
2022-08-23 20:26 | Christian Grothoff | Category | bank (demonstrator) => py bank (demonstrator, obsolete) |