View Issue Details

IDProjectCategoryView StatusLast Update
0006812Talermerchant backend API (C)public2021-04-02 16:04
Reportersebasjm Assigned ToChristian Grothoff  
PriorityhighSeveritymajorReproducibilityalways
Status resolvedResolutionfixed 
Product Versiongit (master) 
Target Version0.9Fixed in Version0.9 
Summary0006812: creation of default instance fail after soft delete
DescriptionAssertion failed when checking that there is just one instance after db insert

ERROR Assertion failed at taler-merchant-httpd_private-post-instances.c:451.
TagsNo tags attached.

Activities

sebasjm

2021-03-17 19:24

developer  

script-recreate-default.sh (1,599 bytes)   
#/bin/bash

ID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 16 | head -n 1)

HOST=https://backend.demo.taler.net
AUTH="ApiKey sandbox"
CURRENCY=KUDOS

set -x
curl -q $HOST/private/instances     -H "Authorization: $AUTH" --data-raw '{"default_wire_transfer_delay":{"d_ms":2000},"auth": { "method": "external" },"default_pay_delay":{"d_ms":1000},"jurisdiction":{},"address":{},"default_wire_fee_amortization":10,"default_max_wire_fee":"'$CURRENCY':2","default_max_deposit_fee":"'$CURRENCY':1","payto_uris":["payto://asd/asd"],"name":"qwe","id":"'$ID'"}'

echo delete with purge work as expeced 

curl -q "$HOST/private/instances/$ID?purge=yes"     -H "Authorization: $AUTH" -X DELETE

curl -q $HOST/private/instances     -H "Authorization: $AUTH" --data-raw '{"default_wire_transfer_delay":{"d_ms":2000},"auth": { "method": "external" },"default_pay_delay":{"d_ms":1000},"jurisdiction":{},"address":{},"default_wire_fee_amortization":10,"default_max_wire_fee":"'$CURRENCY':2","default_max_deposit_fee":"'$CURRENCY':1","payto_uris":["payto://asd/asd"],"name":"qwe","id":"'$ID'"}'

echo this fill make the next create fail

curl -q "$HOST/private/instances/$ID"     -H "Authorization: $AUTH" -X DELETE


curl -q $HOST/private/instances     -H "Authorization: $AUTH" --data-raw '{"default_wire_transfer_delay":{"d_ms":2000},"auth": { "method": "external" },"default_pay_delay":{"d_ms":1000},"jurisdiction":{},"address":{},"default_wire_fee_amortization":10,"default_max_wire_fee":"'$CURRENCY':2","default_max_deposit_fee":"'$CURRENCY':1","payto_uris":["payto://asd/asd"],"name":"qwe","id":"'$ID'"}'
script-recreate-default.sh (1,599 bytes)   

sebasjm

2021-03-17 19:26

developer   ~0017626

this is specially bad when soft deleting default instance

should the backend allow default instance deletion?

Christian Grothoff

2021-03-30 23:37

manager   ~0017660

Good question. I think we should allow deletion, after all that is a good way to clean up everything in test cases. Also, one could conceivably deliberately delete the default instance to disable instance management while keeping other instances around. Now, if deleting the default instance, the only way to recover to the point of being able to do instance management is to setup a fresh instance.

I think the funky case is deleting the default instance without purging it ("soft delete" as you called it). In that case, one cannot create a fresh default instance. But again, I think purging should then still be possible, right? I'll add some tests around this...

Christian Grothoff

2021-04-02 15:28

manager   ~0017671

fd1cac5..9bec95f fixes the error code being returned (409 if instance was deleted but not purged).

Still to do: allow purge after deletion, this currently fails (updated script to create issue attached).
script-recreate-default-2.sh (1,674 bytes)   
#/bin/bash

ID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 16 | head -n 1)

HOST=http://localhost:8080
AUTH="ApiKey sandbox"
CURRENCY=EUR

set -x
curl -q $HOST/private/instances     -H "Authorization: $AUTH" --data-raw '{"default_wire_transfer_delay":{"d_ms":2000},"auth": { "method": "external" },"default_pay_delay":{"d_ms":1000},"jurisdiction":{},"address":{},"default_wire_fee_amortization":10,"default_max_wire_fee":"'$CURRENCY':2","default_max_deposit_fee":"'$CURRENCY':1","payto_uris":["payto://asd/asd"],"name":"qwe","id":"'$ID'"}'

echo delete with purge work as expeced

curl -q "$HOST/instances/$ID/private?purge=yes"     -H "Authorization: $AUTH" -X DELETE

curl -q $HOST/private/instances     -H "Authorization: $AUTH" --data-raw '{"default_wire_transfer_delay":{"d_ms":2000},"auth": { "method": "external" },"default_pay_delay":{"d_ms":1000},"jurisdiction":{},"address":{},"default_wire_fee_amortization":10,"default_max_wire_fee":"'$CURRENCY':2","default_max_deposit_fee":"'$CURRENCY':1","payto_uris":["payto://asd/asd"],"name":"qwe","id":"'$ID'"}'

echo this fill make the next create fail

curl -q "$HOST/instances/$ID/private"     -H "Authorization: $AUTH" -X DELETE
curl -q "$HOST/instances/$ID/private?purge=yes"     -H "Authorization: $AUTH" -X DELETE

curl -q $HOST/private/instances     -H "Authorization: $AUTH" --data-raw '{"default_wire_transfer_delay":{"d_ms":2000},"auth": { "method": "external" },"default_pay_delay":{"d_ms":1000},"jurisdiction":{},"address":{},"default_wire_fee_amortization":10,"default_max_wire_fee":"'$CURRENCY':2","default_max_deposit_fee":"'$CURRENCY':1","payto_uris":["payto://asd/asd"],"name":"qwe","id":"'$ID'"}'
script-recreate-default-2.sh (1,674 bytes)   

Christian Grothoff

2021-04-02 15:58

manager   ~0017672

docs.git: b9d293e..0fd1ff5: GET /private/instances now indicates if an instance has been deleted but not purged.
merchant.git: 9bec95f..385fb34: allows purging previously deleted instances, which means that afterwards it is again possible to create a new instance of the same ID.

Christian Grothoff

2021-04-02 16:04

manager   ~0017673

Sebastian: I consider this resolved. Note: the SPA should now check for the 'deleted' flag and then can still allow the instance to be purged.
Some operations are not permitted on deleted (but not purged) instances, specifically, one cannot create orders, lock products, create refunds, create reserves (see: Tipping), or authorize tips. POSTing transfers I have allowed. See the 'allow_deleted_instance' field in the handler array for which endpoints are permitted for deleted but not purged instances. (I hope I got those right...).

Issue History

Date Modified Username Field Change
2021-03-17 19:24 sebasjm New Issue
2021-03-17 19:24 sebasjm Status new => assigned
2021-03-17 19:24 sebasjm Assigned To => Christian Grothoff
2021-03-17 19:24 sebasjm File Added: script-recreate-default.sh
2021-03-17 19:26 sebasjm Note Added: 0017626
2021-03-30 23:37 Christian Grothoff Note Added: 0017660
2021-03-30 23:37 Christian Grothoff Priority normal => high
2021-03-30 23:37 Christian Grothoff Target Version git (master) => 0.9
2021-03-30 23:37 Christian Grothoff Description Updated View Revisions
2021-04-02 15:28 Christian Grothoff Note Added: 0017671
2021-04-02 15:28 Christian Grothoff File Added: script-recreate-default-2.sh
2021-04-02 15:58 Christian Grothoff Note Added: 0017672
2021-04-02 16:04 Christian Grothoff Status assigned => resolved
2021-04-02 16:04 Christian Grothoff Resolution open => fixed
2021-04-02 16:04 Christian Grothoff Fixed in Version => 0.9
2021-04-02 16:04 Christian Grothoff Note Added: 0017673