View Issue Details

IDProjectCategoryView StatusLast Update
0008945Talermechant backendpublic2024-07-26 00:11
Reportersebasjm Assigned Tosebasjm  
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionfixed 
Product Version0.12 
Target Version0.12Fixed in Version0.12 
Summary0008945: create bank account after deleting it doesn't bring it to active again
Description1.- created an account
2.- removed it
3.- created again and expected to be shown again

Example response

$ curl 'http://merchant.taler.test:1180/private/accounts' -H 'Authorization: Bearer secret-token:C52GC3EQPFNP33BAH8NYAZ4J2YRZ8E3JPP94B0WPYMVWKERNWMKG' -d '{"payto_uri":"payto://iban/DE8282221371627?receiver-name=Husky%20Fun","credit_facade_credentials":{"type":"basic","password":"123","username":"_husky-funny_"},"credit_facade_url":"http://bank.taler.tes1180/accounts/_husky-funny_/taler-revenue/"}'
{
  "code": 53,
  "hint": "The service failed to fetch information from its database. The system administrator should check that the database is running and review the service logs.",
  "detail": "select_account"
}


Jun 14 12:38:22 marvin taler-merchant-httpd[3330577]: (RCRSXDH72BEEX649MXTJ2JT5ZC) INFO Request for `/private/accounts' completed with HTTP status 200 (0)
Jun 14 12:38:45 marvin taler-merchant-httpd[3330577]: (81TJ2TDQRFSVFSEC1DVB8TJN94) INFO Handling request (POST) for URL '/private/accounts'
Jun 14 12:38:45 marvin taler-merchant-httpd[3330577]: (81TJ2TDQRFSVFSEC1DVB8TJN94) ERROR Assertion failed at pq_eval.c:231.
Jun 14 12:38:45 marvin taler-merchant-httpd[3330577]: (81TJ2TDQRFSVFSEC1DVB8TJN94) ERROR Assertion failed at taler-merchant-httpd_private-post-account.c:187.


LOG: duration: 0.032 ms bind insert_account: INSERT INTO merchant_accounts(merchant_serial,h_wire,salt,payto_uri,credit_facade_url,credit_facade_credentials,active) SELECT merchant_serial, $2, $3, $4, $5, $6, $7 FROM merchant_instances WHERE merchant_id=$1
DETAIL: parameters: $1 = 'default', $2 = '\xaff91b313b1377335b9e767d346ba9ab5ba0ce9e59c70acb279cbdc8dc700458fc04c6d6786e409b53aefe1993f36143897f23592e879c7495d9559b25f55c18', $3 = '\x6692614f304a4f1a742971e9ad697bae', $4 = 'payto://iban/DE8282221371627?receiver-name=Husky%20Fun', $5 = 'http://bank.taler.tes1180/accounts/_husky-funny_/taler-revenue/', $6 = '{"type":"basic","password":"123","username":"_husky-funny_"}', $7 = 't'
LOG: execute insert_account: INSERT INTO merchant_accounts(merchant_serial,h_wire,salt,payto_uri,credit_facade_url,credit_facade_credentials,active) SELECT merchant_serial, $2, $3, $4, $5, $6, $7 FROM merchant_instances WHERE merchant_id=$1
DETAIL: parameters: $1 = 'default', $2 = '\xaff91b313b1377335b9e767d346ba9ab5ba0ce9e59c70acb279cbdc8dc700458fc04c6d6786e409b53aefe1993f36143897f23592e879c7495d9559b25f55c18', $3 = '\x6692614f304a4f1a742971e9ad697bae', $4 = 'payto://iban/DE8282221371627?receiver-name=Husky%20Fun', $5 = 'http://bank.taler.tes1180/accounts/_husky-funny_/taler-revenue/', $6 = '{"type":"basic","password":"123","username":"_husky-funny_"}', $7 = 't'
ERROR: duplicate key value violates unique constraint "merchant_accounts_merchant_serial_payto_uri_key"
DETAIL: Key (merchant_serial, payto_uri)=(1, payto://iban/DE8282221371627?receiver-name=Husky%20Fun) already exists.
STATEMENT: INSERT INTO merchant_accounts(merchant_serial,h_wire,salt,payto_uri,credit_facade_url,credit_facade_credentials,active) SELECT merchant_serial, $2, $3, $4, $5, $6, $7 FROM merchant_instances WHERE merchant_id=$1
LOG: duration: 0.026 ms bind select_account_by_uri: SELECT salt,h_wire,credit_facade_url,credit_facade_credentials,active FROM merchant_accounts WHERE merchant_serial= (SELECT merchant_serial FROM merchant_instances WHERE merchant_id=$1) AND REGEXP_REPLACE(payto_uri,'\?.*','') =REGEXP_REPLACE($2,'\?.*','')
DETAIL: parameters: $1 = 'default', $2 = 'payto://iban/DE8282221371627?receiver-name=Husky%20Fun'
LOG: execute select_account_by_uri: SELECT salt,h_wire,credit_facade_url,credit_facade_credentials,active FROM merchant_accounts WHERE merchant_serial= (SELECT merchant_serial FROM merchant_instances WHERE merchant_id=$1) AND REGEXP_REPLACE(payto_uri,'\?.*','') =REGEXP_REPLACE($2,'\?.*','')
DETAIL: parameters: $1 = 'default', $2 = 'payto://iban/DE8282221371627?receiver-name=Husky%20Fun'
LOG: duration: 0.028 ms
TagsNo tags attached.

Relationships

related to 0008926 closedsebasjm merchant SPA doesn't allow editing bank accounts [4hs] 

Activities

sebasjm

2024-06-14 17:59

developer   ~0022609

If I add an account and then delete it, trying to add it again with the same info doesn't bring it back but there is no error. (not expected, the expected result is the bank account to be shown as active again)

If now I try to add a new account with same IBAN but different "receiver-name" this new account is added, as expected.

Only after this trying to add the original payto returns the error mentioned in the issue.

Christian Grothoff

2024-06-15 18:34

manager   ~0022614

The problem is your hack from 1c1ec9c54e09e9b90ea7a91e81bf5a6eb878c53b -- you just masked the disabled accounts instead of returning them. As a result, you're now POSTing instead of using PATCH to enable the account. I'll revert 1c1ec9c54e09e9b90ea7a91e81bf5a6eb878c53b and you should filter accounts client-side (if needed) and use PATCH to re-enable an account that was previously disabled.

sebasjm

2024-06-16 22:59

developer   ~0022633

ok, the only problem I see is: when updating an account (from payto_hash A to payto_hash B) the SPA needs to know whether the payto_hash B already exist to choose between PATCH or POST.

This scenario:
 - create a bank account with owner name Christian
 - change the name to Florian
 - change the name to Christian again

In the second step, the SPA needs to do a POST (adding a new bank account) in the third it should be a PATCH (activating the first account).

I guess that this could be workaround as always sending PATCH and if it fails try a POST.

Issue History

Date Modified Username Field Change
2024-06-14 17:51 sebasjm New Issue
2024-06-14 17:51 sebasjm Status new => assigned
2024-06-14 17:51 sebasjm Assigned To => Christian Grothoff
2024-06-14 17:59 sebasjm Note Added: 0022609
2024-06-14 19:22 sebasjm Relationship added related to 0008926
2024-06-15 18:34 Christian Grothoff Note Added: 0022614
2024-06-15 18:36 Christian Grothoff Assigned To Christian Grothoff => sebasjm
2024-06-16 22:59 sebasjm Status assigned => resolved
2024-06-16 22:59 sebasjm Resolution open => fixed
2024-06-16 22:59 sebasjm Note Added: 0022633
2024-07-26 00:11 Christian Grothoff Fixed in Version => 0.12
2024-07-26 00:11 Christian Grothoff Status resolved => closed