View Issue Details

IDProjectCategoryView StatusLast Update
0006445Talermerchant backendpublic2024-01-12 13:04
ReporterChristian Grothoff Assigned ToChristian Grothoff Resolution deadline
ImplementerReviewer 
Release signed byDeployed by 
VerifierCommunicator 
Data protection authority notification requiredNo  
CSIRT notification requiredNo  
Estimated effort (hours)Actual effort (hours)0 
Fast-trackNo
Work packagenone
PriorityhighSeveritymajorReproducibilityalways
Status closedResolutionreopened 
Platformi7OSDebian GNU/LinuxOS Versionsqueeze
Product Versiongit (master) 
Target Version0.8Fixed in Version0.8 
Summary0006445: POST /private/orders is not idempotent
DescriptionIf a client posts _exactly_ the same request to /private/orders *with* an order_id specified (!), we currently generate an error.
Instead, we should create exactly the same response a 2nd time.

(Note that this ONLY applies if the client includes the order_id; if there is no order_id, we create one at random so the 2nd response would be different.)

Fixing this requires additional logic to check that the request has an order_id and that we have exactly the same order (with the same terms) in the database. This is a bit tricky, as we modify/patch the order (adding merchant details, etc.), so really we can only do the idempotentcy check _after_ patching the incoming order.
TagsNo tags attached.

Required notifications

Address or linkRemarkAdded byNotifiedActions

Activities

jonathanbuchanan

2020-08-02 02:01

reporter   ~0016540

implemented in 859675f..b90d7d2.

Christian Grothoff

2020-09-03 21:50

manager   ~0016832

Actually, the fix doesn't work, I just encountered this with my WooCommerce tests. You do:

   if (1 == json_equal (order,
                           contract_terms))

which likely fails because the stored contract_terms have been modified by the backend, and either (didn't check):
- the 'order' has not yet been modified
- the modifications are not exactly the same, say because we are adding some relative time as an offset and then
  the result ends up _slightly_ different.

So yeah, getting this right will be a bit funky. :-(

I propose we only compare a few fields:
- products
- summary / summary_i18n
- fulfillment_url
- locations
- total price
- order_id (doh)
- auto_refund
- extra

and leave out the timestamps. Hopefully that'll work...

Christian Grothoff

2020-09-05 11:20

manager   ~0016869

c0f9922..6f8c224 implements a more principled approach by storing the hash of the original POST request into the DB and we check against that for idempotency.

Christian Grothoff

2020-09-05 11:27

manager   ~0016870

Deployments updated.

Issue History

Date ModifiedUsernameFieldChange
2020-07-25 19:17Christian GrothoffNew Issue
2020-07-25 19:17Christian GrothoffStatusnew => assigned
2020-07-25 19:17Christian GrothoffAssigned To => jonathanbuchanan
2020-08-02 02:01jonathanbuchananStatusassigned => informing
2020-08-02 02:01jonathanbuchananResolutionopen => fixed
2020-08-02 02:01jonathanbuchananNote Added: 0016540
2020-08-06 23:44Christian GrothoffFixed in Version => 0.8
2020-09-03 21:46Christian GrothoffAssigned Tojonathanbuchanan => Christian Grothoff
2020-09-03 21:46Christian GrothoffAssigned ToChristian Grothoff => jonathanbuchanan
2020-09-03 21:50Christian GrothoffStatusinforming => feedback
2020-09-03 21:50Christian GrothoffResolutionfixed => reopened
2020-09-03 21:50Christian GrothoffNote Added: 0016832
2020-09-04 23:47Christian GrothoffAssigned Tojonathanbuchanan => Christian Grothoff
2020-09-04 23:47Christian GrothoffPrioritynormal => high
2020-09-04 23:47Christian GrothoffStatusfeedback => assigned
2020-09-05 11:20Christian GrothoffNote Added: 0016869
2020-09-05 11:27Christian GrothoffStatusassigned => informing
2020-09-05 11:27Christian GrothoffNote Added: 0016870
2021-08-24 14:23Christian GrothoffStatusinforming => closed
2024-01-12 13:04Christian GrothoffCategorymerchant backend API (C) => mechant backend
2025-03-22 13:09Christian GrothoffCategorymechant backend => merchant backend