-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotes_tutorial.txt
More file actions
491 lines (421 loc) · 38.7 KB
/
notes_tutorial.txt
File metadata and controls
491 lines (421 loc) · 38.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
Run the Restate server
----------------------
chaschel@xia:~$ docker run --name restate_dev --rm \
-p 8080:8080 -p 9070:9070 -p 9071:9071 \
--add-host=host.docker.internal:host-gateway \
docker.io/restatedev/restate:latest
32e088a500c2163b94305723f1c5339763ac0b8a95d029a8c9488af3fcdb94c4
chaschel@xia:~$
Note: For simplicity, there is a built-in user account named alice that is logged in already
Register the services
---------------------
chaschel@xia:~/Documents/ibm/go/apps/zeroapp/prototype$ register-services.sh
register-services.sh: command not found
chaschel@xia:~/Documents/ibm/go/apps/zeroapp/prototype$ ./register-services.sh
📝 Registering services with Restate runtime...
Using service URI: http://172.17.0.1:9089
❌ Registration failed with HTTP 500
{"message":"[META0003] error when calling 'http://172.17.0.1:9089/': unable to reach the remote endpoint.\nReason: client error (Connect) caused by: tcp connect error caused by: Connection refused (os error 111)","restate_code":"META0003"}
chaschel@xia:~/Documents/ibm/go/apps/zeroapp/prototype$ ./register-services.sh
📝 Registering services with Restate runtime...
Using service URI: http://172.17.0.1:9090
✅ Services registered successfully!
Registered services:
OrderFulfillmentWorkflow
ShippingService
UserSession
🎉 Setup complete! You can now use the application.
Test endpoints:
curl -H 'X-User-ID: alice' http://localhost:8081/api/cart
chaschel@xia:~/Documents/ibm/go/apps/zeroapp/prototype$
Run the app
-----------
chaschel@xia:~/Documents/ibm/go/apps/zeroapp/prototype/backend$ ls
bin data db go.mod go.sum handlers main.go models services zeroapp
chaschel@xia:~/Documents/ibm/go/apps/zeroapp/prototype/backend$ ./zeroapp
✓ Executed migration: 001_init.sql
✓ Executed migration: 002_seed.sql
2025/12/03 10:45:56 ✓ Database initialized successfully
2025/12/03 10:45:56 Starting Restate server on :9090
2025/12/03 10:45:56 WARN Accepting requests without validating request signatures; handler access must be restricted
2025/12/03 10:45:56 INFO Restate SDK started listening on [::]:9090
2025/12/03 10:45:57 ✓ Starting HTTP server on :8082
2025/12/03 10:45:57 ✓ Frontend: http://localhost:8082
2025/12/03 10:45:57 ✓ Admin UI: http://localhost:8082/admin
2025/12/03 10:45:57 ✓ Restate server running on :9090
2025/12/03 10:46:17 "GET http://localhost:8082/ HTTP/1.1" from [::1]:39890 - 304 0B in 1.622229ms
2025/12/03 10:46:17 "GET http://localhost:8082/static/css/reset.css HTTP/1.1" from [::1]:39890 - 304 0B in 71.003µs
2025/12/03 10:46:17 "GET http://localhost:8082/static/css/variables.css HTTP/1.1" from [::1]:39890 - 304 0B in 54.943µs
2025/12/03 10:46:17 "GET http://localhost:8082/static/css/layout.css HTTP/1.1" from [::1]:39900 - 304 0B in 52.448µs
2025/12/03 10:46:17 "GET http://localhost:8082/static/css/components.css HTTP/1.1" from [::1]:39906 - 304 0B in 105.808µs
2025/12/03 10:46:17 "GET http://localhost:8082/static/js/main.js HTTP/1.1" from [::1]:39890 - 304 0B in 47.87µs
2025/12/03 10:46:17 "GET http://localhost:8082/static/js/tabs.js HTTP/1.1" from [::1]:39900 - 304 0B in 46.437µs
2025/12/03 10:46:17 "GET http://localhost:8082/static/js/navigation.js HTTP/1.1" from [::1]:39906 - 304 0B in 57.728µs
2025/12/03 10:46:17 "GET http://localhost:8082/favicon.ico HTTP/1.1" from [::1]:39900 - 404 19B in 14.207µs
2025/12/03 10:46:21 ✓ Authenticated user: alice
2025/12/03 10:46:21 GetCart: user=alice
2025/12/03 10:46:21 Error fetching cart for user alice: service 'UserSession' not found, make sure to register the service before calling it.
2025/12/03 10:46:21 "GET http://localhost:8082/api/cart HTTP/1.1" from [::1]:39900 - 500 108B in 3.939153ms
2025/12/03 10:46:40 "GET http://localhost:8082/api/products HTTP/1.1" from [::1]:39900 - 200 1026B in 275.688µs
2025/12/03 10:46:41 ✓ Authenticated user: alice
2025/12/03 10:46:41 AddToCart: user=alice, product=3, quantity=1
2025/12/03 10:46:41 Error adding item to cart for user alice: service 'UserSession' not found, make sure to register the service before calling it.
2025/12/03 10:46:41 "POST http://localhost:8082/api/cart/add HTTP/1.1" from [::1]:39900 - 500 106B in 543.181µs
2025/12/03 10:46:50 ✓ Authenticated user: alice
2025/12/03 10:46:50 GetCart: user=alice
2025/12/03 10:46:50 Error fetching cart for user alice: service 'UserSession' not found, make sure to register the service before calling it.
2025/12/03 10:46:50 "GET http://localhost:8082/api/cart HTTP/1.1" from [::1]:39900 - 500 108B in 400.923µs
2025/12/03 10:49:33 "GET http://localhost:8082/api/products HTTP/1.1" from [::1]:39900 - 200 1026B in 4.635402ms
2025/12/03 10:49:34 ✓ Authenticated user: alice
2025/12/03 10:49:34 GetCart: user=alice
2025/12/03 10:49:34 INFO Handling invocation method=UserSession/GetBasket invocationID=inv_1l3Hc716hrBy3wNwPmBtOiJI9Mqy8AuKLn
2025/12/03 10:49:34 INFO Fetching cart method=UserSession/GetBasket invocationID=inv_1l3Hc716hrBy3wNwPmBtOiJI9Mqy8AuKLn user_id=alice
2025/12/03 10:49:34 INFO Invocation completed successfully method=UserSession/GetBasket invocationID=inv_1l3Hc716hrBy3wNwPmBtOiJI9Mqy8AuKLn
2025/12/03 10:49:34 Successfully fetched cart for user alice: 0 items
2025/12/03 10:49:34 "GET http://localhost:8082/api/cart HTTP/1.1" from [::1]:39900 - 200 3B in 18.374635ms
2025/12/03 10:49:40 "GET http://localhost:8082/api/products HTTP/1.1" from [::1]:39900 - 200 1026B in 242.095µs
2025/12/03 10:49:41 ✓ Authenticated user: alice
2025/12/03 10:49:41 AddToCart: user=alice, product=3, quantity=1
2025/12/03 10:49:41 INFO Handling invocation method=UserSession/AddItem invocationID=inv_1l3Hc716hrBy20MKkveVtjROHAvTg67625
2025/12/03 10:49:41 INFO Adding item to cart method=UserSession/AddItem invocationID=inv_1l3Hc716hrBy20MKkveVtjROHAvTg67625 user_id=alice product_id=3
2025/12/03 10:49:41 INFO Cart updated method=UserSession/AddItem invocationID=inv_1l3Hc716hrBy20MKkveVtjROHAvTg67625 user_id=alice total_items=1
2025/12/03 10:49:41 INFO Invocation completed successfully method=UserSession/AddItem invocationID=inv_1l3Hc716hrBy20MKkveVtjROHAvTg67625
2025/12/03 10:49:41 Successfully added item to cart for user alice
2025/12/03 10:49:41 "POST http://localhost:8082/api/cart/add HTTP/1.1" from [::1]:39900 - 200 48B in 11.281243ms
2025/12/03 10:49:41 ✓ Authenticated user: alice
2025/12/03 10:49:41 GetCart: user=alice
2025/12/03 10:49:41 INFO Handling invocation method=UserSession/GetBasket invocationID=inv_1l3Hc716hrBy0xCyabRAeML6p3bwchdRPH
2025/12/03 10:49:41 INFO Fetching cart method=UserSession/GetBasket invocationID=inv_1l3Hc716hrBy0xCyabRAeML6p3bwchdRPH user_id=alice
2025/12/03 10:49:41 INFO Invocation completed successfully method=UserSession/GetBasket invocationID=inv_1l3Hc716hrBy0xCyabRAeML6p3bwchdRPH
2025/12/03 10:49:41 Successfully fetched cart for user alice: 1 items
2025/12/03 10:49:41 "GET http://localhost:8082/api/cart HTTP/1.1" from [::1]:39900 - 200 91B in 5.956254ms
2025/12/03 10:50:12 "GET http://localhost:8082/api/products HTTP/1.1" from [::1]:39900 - 200 1026B in 242.646µs
2025/12/03 10:50:14 ✓ Authenticated user: alice
2025/12/03 10:50:14 AddToCart: user=alice, product=4, quantity=1
2025/12/03 10:50:14 INFO Handling invocation method=UserSession/AddItem invocationID=inv_1l3Hc716hrBy35jxXk5Ck7nlpT4JqiaZy1
2025/12/03 10:50:14 INFO Adding item to cart method=UserSession/AddItem invocationID=inv_1l3Hc716hrBy35jxXk5Ck7nlpT4JqiaZy1 user_id=alice product_id=4
2025/12/03 10:50:14 INFO Cart updated method=UserSession/AddItem invocationID=inv_1l3Hc716hrBy35jxXk5Ck7nlpT4JqiaZy1 user_id=alice total_items=2
2025/12/03 10:50:14 INFO Invocation completed successfully method=UserSession/AddItem invocationID=inv_1l3Hc716hrBy35jxXk5Ck7nlpT4JqiaZy1
2025/12/03 10:50:14 Successfully added item to cart for user alice
2025/12/03 10:50:14 "POST http://localhost:8082/api/cart/add HTTP/1.1" from [::1]:39900 - 200 48B in 10.668081ms
2025/12/03 10:50:14 ✓ Authenticated user: alice
2025/12/03 10:50:14 GetCart: user=alice
2025/12/03 10:50:14 INFO Handling invocation method=UserSession/GetBasket invocationID=inv_1l3Hc716hrBy3EccHL9F36aNa8ROvmQnbr
2025/12/03 10:50:14 INFO Fetching cart method=UserSession/GetBasket invocationID=inv_1l3Hc716hrBy3EccHL9F36aNa8ROvmQnbr user_id=alice
2025/12/03 10:50:14 INFO Invocation completed successfully method=UserSession/GetBasket invocationID=inv_1l3Hc716hrBy3EccHL9F36aNa8ROvmQnbr
2025/12/03 10:50:14 Successfully fetched cart for user alice: 2 items
2025/12/03 10:50:14 "GET http://localhost:8082/api/cart HTTP/1.1" from [::1]:39900 - 200 180B in 5.965743ms
2025/12/03 10:50:41 "GET http://localhost:8082/admin HTTP/1.1" from [::1]:39900 - 304 0B in 76.524µs
2025/12/03 10:50:41 "GET http://localhost:8082/static/js/admin.js HTTP/1.1" from [::1]:39900 - 304 0B in 93.716µs
2025/12/03 10:50:49 ✓ Authenticated user: alice
2025/12/03 10:50:49 "GET http://localhost:8082/api/orders HTTP/1.1" from [::1]:39890 - 200 3B in 427.974µs
2025/12/03 10:50:50 ✓ Authenticated user: alice
2025/12/03 10:50:50 GetCart: user=alice
2025/12/03 10:50:50 INFO Handling invocation method=UserSession/GetBasket invocationID=inv_1l3Hc716hrBy2oz9Z1nvjb4uyJmbpQxobv
2025/12/03 10:50:50 INFO Fetching cart method=UserSession/GetBasket invocationID=inv_1l3Hc716hrBy2oz9Z1nvjb4uyJmbpQxobv user_id=alice
2025/12/03 10:50:50 INFO Invocation completed successfully method=UserSession/GetBasket invocationID=inv_1l3Hc716hrBy2oz9Z1nvjb4uyJmbpQxobv
2025/12/03 10:50:50 Successfully fetched cart for user alice: 2 items
2025/12/03 10:50:50 "GET http://localhost:8082/api/cart HTTP/1.1" from [::1]:39890 - 200 180B in 8.699581ms
2025/12/03 10:50:51 "GET http://localhost:8082/api/products HTTP/1.1" from [::1]:39890 - 200 1026B in 227.197µs
2025/12/03 10:51:00 ✓ Authenticated user: alice
2025/12/03 10:51:00 GetCart: user=alice
2025/12/03 10:51:00 INFO Handling invocation method=UserSession/GetBasket invocationID=inv_1l3Hc716hrBy4ktZo5W9zUX3rjq7agoMiB
2025/12/03 10:51:00 INFO Fetching cart method=UserSession/GetBasket invocationID=inv_1l3Hc716hrBy4ktZo5W9zUX3rjq7agoMiB user_id=alice
2025/12/03 10:51:00 INFO Invocation completed successfully method=UserSession/GetBasket invocationID=inv_1l3Hc716hrBy4ktZo5W9zUX3rjq7agoMiB
2025/12/03 10:51:00 Successfully fetched cart for user alice: 2 items
2025/12/03 10:51:00 "GET http://localhost:8082/api/cart HTTP/1.1" from [::1]:39890 - 200 180B in 9.011056ms
2025/12/03 10:52:37 "GET http://localhost:8082/api/products HTTP/1.1" from [::1]:39890 - 200 1026B in 236.284µs
2025/12/03 10:52:39 ✓ Authenticated user: alice
2025/12/03 10:52:39 GetCart: user=alice
2025/12/03 10:52:39 INFO Handling invocation method=UserSession/GetBasket invocationID=inv_1l3Hc716hrBy7eB8GiDEq9mziYLs4PS8dX
2025/12/03 10:52:39 INFO Fetching cart method=UserSession/GetBasket invocationID=inv_1l3Hc716hrBy7eB8GiDEq9mziYLs4PS8dX user_id=alice
2025/12/03 10:52:39 INFO Invocation completed successfully method=UserSession/GetBasket invocationID=inv_1l3Hc716hrBy7eB8GiDEq9mziYLs4PS8dX
2025/12/03 10:52:39 Successfully fetched cart for user alice: 2 items
2025/12/03 10:52:39 "GET http://localhost:8082/api/cart HTTP/1.1" from [::1]:39890 - 200 180B in 9.583803ms
2025/12/03 10:52:42 "GET http://localhost:8082/api/products HTTP/1.1" from [::1]:39890 - 200 1026B in 199.355µs
2025/12/03 10:52:54 ✓ Authenticated user: alice
2025/12/03 10:52:54 "GET http://localhost:8082/api/orders HTTP/1.1" from [::1]:39890 - 200 3B in 173.396µs
2025/12/03 10:52:57 ✓ Authenticated user: alice
2025/12/03 10:52:57 GetCart: user=alice
2025/12/03 10:52:57 INFO Handling invocation method=UserSession/GetBasket invocationID=inv_1l3Hc716hrBy7xSBM9mpLWAfEazNXW1Thf
2025/12/03 10:52:57 INFO Fetching cart method=UserSession/GetBasket invocationID=inv_1l3Hc716hrBy7xSBM9mpLWAfEazNXW1Thf user_id=alice
2025/12/03 10:52:57 INFO Invocation completed successfully method=UserSession/GetBasket invocationID=inv_1l3Hc716hrBy7xSBM9mpLWAfEazNXW1Thf
2025/12/03 10:52:57 Successfully fetched cart for user alice: 2 items
2025/12/03 10:52:57 "GET http://localhost:8082/api/cart HTTP/1.1" from [::1]:39890 - 200 180B in 15.228201ms
2025/12/03 10:58:43 ✓ Authenticated user: alice
2025/12/03 10:58:43 "GET http://localhost:8082/api/orders HTTP/1.1" from [::1]:41792 - 200 3B in 327.645µs
2025/12/03 10:58:45 ✓ Authenticated user: alice
2025/12/03 10:58:45 GetCart: user=alice
2025/12/03 10:58:45 INFO Handling invocation method=UserSession/GetBasket invocationID=inv_1l3Hc716hrBy2g96BP0GjmzxWkm3s2srcJ
2025/12/03 10:58:45 INFO Fetching cart method=UserSession/GetBasket invocationID=inv_1l3Hc716hrBy2g96BP0GjmzxWkm3s2srcJ user_id=alice
2025/12/03 10:58:45 INFO Invocation completed successfully method=UserSession/GetBasket invocationID=inv_1l3Hc716hrBy2g96BP0GjmzxWkm3s2srcJ
2025/12/03 10:58:45 Successfully fetched cart for user alice: 2 items
2025/12/03 10:58:45 "GET http://localhost:8082/api/cart HTTP/1.1" from [::1]:41792 - 200 180B in 10.237692ms
2025/12/03 11:00:13 ✓ Authenticated user: alice
2025/12/03 11:00:13 "GET http://localhost:8082/api/orders HTTP/1.1" from [::1]:41792 - 200 3B in 157.386µs
2025/12/03 11:00:14 "GET http://localhost:8082/api/products HTTP/1.1" from [::1]:41792 - 200 1026B in 199.666µs
2025/12/03 11:00:16 ✓ Authenticated user: alice
2025/12/03 11:00:16 GetCart: user=alice
2025/12/03 11:00:16 INFO Handling invocation method=UserSession/GetBasket invocationID=inv_1l3Hc716hrBy2459IeQdtuw7ns7O2ElDjP
2025/12/03 11:00:16 INFO Fetching cart method=UserSession/GetBasket invocationID=inv_1l3Hc716hrBy2459IeQdtuw7ns7O2ElDjP user_id=alice
2025/12/03 11:00:16 INFO Invocation completed successfully method=UserSession/GetBasket invocationID=inv_1l3Hc716hrBy2459IeQdtuw7ns7O2ElDjP
2025/12/03 11:00:16 Successfully fetched cart for user alice: 2 items
2025/12/03 11:00:16 "GET http://localhost:8082/api/cart HTTP/1.1" from [::1]:41792 - 200 180B in 8.019523ms
2025/12/03 11:00:19 ✓ Authenticated user: alice
2025/12/03 11:00:19 "GET http://localhost:8082/api/orders HTTP/1.1" from [::1]:41792 - 200 3B in 166.012µs
2025/12/03 11:00:22 ✓ Authenticated user: alice
2025/12/03 11:00:22 GetCart: user=alice
2025/12/03 11:00:22 INFO Handling invocation method=UserSession/GetBasket invocationID=inv_1l3Hc716hrBy1hiRVjk7inrm8TDdTJ9mWR
2025/12/03 11:00:22 INFO Fetching cart method=UserSession/GetBasket invocationID=inv_1l3Hc716hrBy1hiRVjk7inrm8TDdTJ9mWR user_id=alice
2025/12/03 11:00:22 INFO Invocation completed successfully method=UserSession/GetBasket invocationID=inv_1l3Hc716hrBy1hiRVjk7inrm8TDdTJ9mWR
2025/12/03 11:00:22 Successfully fetched cart for user alice: 2 items
2025/12/03 11:00:22 "GET http://localhost:8082/api/cart HTTP/1.1" from [::1]:41792 - 200 180B in 29.442016ms
2025/12/03 11:00:27 ✓ Authenticated user: alice
2025/12/03 11:00:27 "POST http://localhost:8082/api/checkout HTTP/1.1" from [::1]:41792 - 202 119B in 8.271306ms
2025/12/03 11:00:27 INFO Handling invocation method=UserSession/Checkout invocationID=inv_1l3Hc716hrBy4uuKsOLPSdo8uYnMx47FRv
2025/12/03 11:00:27 INFO User initiating checkout method=UserSession/Checkout invocationID=inv_1l3Hc716hrBy4uuKsOLPSdo8uYnMx47FRv user_id=alice order_id=order-alice-1764730827836
2025/12/03 11:00:27 INFO Notifying external Payment Gateway method=UserSession/Checkout invocationID=inv_1l3Hc716hrBy4uuKsOLPSdo8uYnMx47FRv awakeable_id=sign_1_HkLWEhiS_UBmuIndD4PiYhHnDBGt5aTAAAAEQ amount_cents=19500
2025/12/03 11:00:27 INFO Awaiting payment confirmation method=UserSession/Checkout invocationID=inv_1l3Hc716hrBy4uuKsOLPSdo8uYnMx47FRv order_id=order-alice-1764730827836 awakeable_id=sign_1_HkLWEhiS_UBmuIndD4PiYhHnDBGt5aTAAAAEQ
2025/12/03 11:01:27 INFO Suspending invocation method=UserSession/Checkout invocationID=inv_1l3Hc716hrBy4uuKsOLPSdo8uYnMx47FRv
Test the app
------------
Products > Add any product to cart
Cart > Check the total price > Checkout button
Check the notifications to the right
Example:
Checkout Initiated
Order order-alice-1764730827836: Awaiting payment. Use curl to simulate payment callback.
Cart > Output tab
Example:
Checkout Initiated
Order ID: order-alice-1764731520807
Payment Simulation
To simulate payment, run this curl command:
curl -X POST http://localhost:8080/api/payment/callback \
-H "Content-Type: application/json" \
-d '{"awakeable_id": "REPLACE_WITH_ID_FROM_LOGS", "transaction_id": "txn-1764731520815", "amount": 10000, "status": "success"}'
Note: REPLACE_WITH_ID_FROM_LOGS
2025/12/03 11:00:27 INFO Notifying external Payment Gateway method=UserSession/Checkout invocationID=inv_1l3Hc716hrBy4uuKsOLPSdo8uYnMx47FRv awakeable_id=sign_1_HkLWEhiS_UBmuIndD4PiYhHnDBGt5aTAAAAEQ amount_cents=19500
awakeable_id=sign_1_HkLWEhiS_UBmuIndD4PiYhHnDBGt5aTAAAAEQ
So:
curl -X POST http://localhost:8080/api/payment/callback \
-H "Content-Type: application/json" \
-d '{"awakeable_id": "sign_1_HkLWEhiS_UBmuIndD4PiYhHnDBGt5aTAAAAEQ", "transaction_id": "txn-1764731520815", "amount": 10000, "status": "success"}'
Output:
{"message":"service 'api' not found, make sure to register the service before calling it."}
Troubleshooting:
From Gemni 3 Pro:
Debugging 'service api not found' error
I confirmed that the backend HTTP server is running on port 8082, while the Restate server is on port 9090. The user was curling port 8080, which is likely the Restate ingress port, causing the "service 'api' not found" error. I will now instruct the user to use port 8082.
Suggestion:
You are curling port 8080, but your backend API is running on port 8082. Please try curling http://localhost:8082/api/payment/callback instead.
curl -X POST http://localhost:8082/api/payment/callback \
-H "Content-Type: application/json" \
-d '{"awakeable_id": "sign_1_HkLWEhiS_UBmuIndD4PiYhHnDBGt5aTAAAAEQ", "transaction_id": "txn-1764731520815", "amount": 10000, "status": "success"}'
Output:
{"message":"Payment callback processed, awakeable sign_1_HkLWEhiS_UBmuIndD4PiYhHnDBGt5aTAAAAEQ resolved","success":true}
Prompt:
it's success, now what? how does the workflow example in the program continue
Gemini 3 Pro:
Great! The payment callback has successfully triggered the OrderFulfillmentWorkflow.
The workflow is now paused at the Admin Approval step. To proceed, you need to approve the order using the following command (replace order-test-2 with your actual order ID if different):
curl -X POST http://localhost:8082/api/workflow/order-test-2/approve \
-H "Content-Type: application/json" \
-d '{"approved": true}'
After approval, the workflow will:
Initiate shipping via ShippingService.
Sleep for 5 seconds (simulating delivery).
Complete the order.
From app:
Checkout Initiated
Order order-alice-1764733182942: Awaiting payment. Use curl to simulate payment callback.
So:
curl -X POST http://localhost:8082/api/workflow/order-alice-1764733182942/approve \
-H "Content-Type: application/json" \
-d '{"approved": true}'
Output from backend:
2025/12/03 12:25:56 INFO Handling invocation method=OrderFulfillmentWorkflow/OnApprove invocationID=inv_1cpj20lt0VT44xQMPyTBS2QmikGWm40TBL
2025/12/03 12:25:56 INFO Shared context handler received approval signal method=OrderFulfillmentWorkflow/OnApprove invocationID=inv_1cpj20lt0VT44xQMPyTBS2QmikGWm40TBL order_id=order-alice-1764733182942 approved=true
2025/12/03 12:25:56 INFO Invocation completed successfully method=OrderFulfillmentWorkflow/OnApprove invocationID=inv_1cpj20lt0VT44xQMPyTBS2QmikGWm40TBL
Troubleshooting:
I found the issue in the Admin Frontend. The "Approve" button was using a custom attribute data-on-submit that wasn't being processed, so clicking it did nothing.
I have fixed frontend/admin.html and frontend/js/admin.js to use the standard onsubmit event.
Please refresh the Admin page and try clicking "Approve" again. It should now work correctly and show an alert upon success.
Note:
If you try to approve THE SAME ORDER ID again, it will fail.
2025/12/03 12:32:08 INFO Handling invocation method=OrderFulfillmentWorkflow/OnApprove invocationID=inv_1cpj20lt0VT42Xr80q7huCivplm3BfqJNL
2025/12/03 12:32:08 INFO Shared context handler received approval signal method=OrderFulfillmentWorkflow/OnApprove invocationID=inv_1cpj20lt0VT42Xr80q7huCivplm3BfqJNL order_id=order-alice-1764733182942 approved=true
2025/12/03 12:32:08 ERROR Invocation returned a terminal failure method=OrderFulfillmentWorkflow/OnApprove invocationID=inv_1cpj20lt0VT42Xr80q7huCivplm3BfqJNL err="[409] promise was already completed"
2025/12/03 12:32:08 Error approving workflow order-alice-1764733182942: request failed with unexpected status 409 Conflict: {"code":409,"message":"[409] promise was already completed"}
Debugging JSON Error on Approval
I updated
backend/handlers/ingress.go
to return a JSON error response instead of plain text. This will prevent the "Unexpected token" error in the frontend. The underlying error is likely due to the workflow already being completed.
I've fixed the backend to return proper JSON errors, so you won't see that "Unexpected token" error anymore.
However, the reason you got an error at all is likely because you already approved this order via curl.
The workflow for order-alice-1764733182942 has likely already moved past the approval step or completed. Trying to approve it again will fail because the "admin_approval" promise has already been resolved.
You can verify the order status by checking the logs or creating a new order to test the UI flow from scratch.
Reject order
------------
order-alice-1764701674755
From admin,
Are you sure you want to reject order order-alice-1764701674755? This will trigger compensations.
Failed to reject order: Unexpected token 'F', "Failed to "... is not valid JSON
Output:
2025/12/03 12:37:00 INFO Handling invocation method=OrderFulfillmentWorkflow/OnApprove invocationID=inv_12jt3wDPA0RA7cZ8y25exPjCZ8h7oXwKyt
2025/12/03 12:37:00 INFO Shared context handler received approval signal method=OrderFulfillmentWorkflow/OnApprove invocationID=inv_12jt3wDPA0RA7cZ8y25exPjCZ8h7oXwKyt order_id=order-alice-1764701674755 approved=false
2025/12/03 12:37:00 ERROR Invocation returned a terminal failure method=OrderFulfillmentWorkflow/OnApprove invocationID=inv_12jt3wDPA0RA7cZ8y25exPjCZ8h7oXwKyt err="[409] promise was already completed"
2025/12/03 12:37:00 Error approving workflow order-alice-1764701674755: request failed with unexpected status 409 Conflict: {"code":409,"message":"[409] promise was already completed"}
Prompt:
fix the admin portal (frontend) such that it will display all orders per All Orders in left sidebar and all notifications per Notification in left sidebar
Test again, new order (order-alice-1764738104158):
curl -X POST http://localhost:8082/api/payment/callback \
-H "Content-Type: application/json" \
-d '{"awakeable_id": "sign_1_HkLWEhiS_UBmuKWe2BcWfS109btRiv6AAAAEQ", "transaction_id": "txn-1764738104167", "amount": 10000, "status": "success"}'
Output after approving order id order-alice-1764738104158 from admin portal:
~/Documents/ibm/go/apps/zeroapp/prototype/backend$ ./zeroapp
✓ Executed migration: 001_init.sql
✓ Executed migration: 002_seed.sql
2025/12/03 13:00:59 ✓ Database initialized successfully
2025/12/03 13:00:59 Starting Restate server on :9090
2025/12/03 13:00:59 WARN Accepting requests without validating request signatures; handler access must be restricted
2025/12/03 13:00:59 INFO Restate SDK started listening on [::]:9090
2025/12/03 13:00:59 ✓ Starting HTTP server on :8082
2025/12/03 13:00:59 ✓ Frontend: http://localhost:8082
2025/12/03 13:00:59 ✓ Admin UI: http://localhost:8082/admin
2025/12/03 13:00:59 ✓ Restate server running on :9090
2025/12/03 13:01:05 "GET http://localhost:8082/api/products HTTP/1.1" from [::1]:48324 - 200 1026B in 319.618µs
2025/12/03 13:01:06 ✓ Authenticated user: alice
2025/12/03 13:01:06 GetCart: user=alice
2025/12/03 13:01:06 INFO Handling invocation method=UserSession/GetBasket invocationID=inv_1l3Hc716hrBy1cXskNBGGfE90tSVLypXTb
2025/12/03 13:01:06 INFO Fetching cart method=UserSession/GetBasket invocationID=inv_1l3Hc716hrBy1cXskNBGGfE90tSVLypXTb user_id=alice
2025/12/03 13:01:06 INFO Invocation completed successfully method=UserSession/GetBasket invocationID=inv_1l3Hc716hrBy1cXskNBGGfE90tSVLypXTb
2025/12/03 13:01:06 Successfully fetched cart for user alice: 0 items
2025/12/03 13:01:06 "GET http://localhost:8082/api/cart HTTP/1.1" from [::1]:48324 - 200 3B in 14.322957ms
2025/12/03 13:01:10 "GET http://localhost:8082/api/products HTTP/1.1" from [::1]:48324 - 200 1026B in 264.793µs
2025/12/03 13:01:12 ✓ Authenticated user: alice
2025/12/03 13:01:12 AddToCart: user=alice, product=2, quantity=1
2025/12/03 13:01:12 INFO Handling invocation method=UserSession/AddItem invocationID=inv_1l3Hc716hrBy1NCBNBwHRCQ8wvtzuEu7wl
2025/12/03 13:01:12 INFO Adding item to cart method=UserSession/AddItem invocationID=inv_1l3Hc716hrBy1NCBNBwHRCQ8wvtzuEu7wl user_id=alice product_id=2
2025/12/03 13:01:12 INFO Cart updated method=UserSession/AddItem invocationID=inv_1l3Hc716hrBy1NCBNBwHRCQ8wvtzuEu7wl user_id=alice total_items=1
2025/12/03 13:01:12 INFO Invocation completed successfully method=UserSession/AddItem invocationID=inv_1l3Hc716hrBy1NCBNBwHRCQ8wvtzuEu7wl
2025/12/03 13:01:12 Successfully added item to cart for user alice
2025/12/03 13:01:12 "POST http://localhost:8082/api/cart/add HTTP/1.1" from [::1]:48324 - 200 48B in 11.082848ms
2025/12/03 13:01:12 ✓ Authenticated user: alice
2025/12/03 13:01:12 GetCart: user=alice
2025/12/03 13:01:12 INFO Handling invocation method=UserSession/GetBasket invocationID=inv_1l3Hc716hrBy44DV3XS2eyBfjTui2Ntq0N
2025/12/03 13:01:12 INFO Fetching cart method=UserSession/GetBasket invocationID=inv_1l3Hc716hrBy44DV3XS2eyBfjTui2Ntq0N user_id=alice
2025/12/03 13:01:12 INFO Invocation completed successfully method=UserSession/GetBasket invocationID=inv_1l3Hc716hrBy44DV3XS2eyBfjTui2Ntq0N
2025/12/03 13:01:12 Successfully fetched cart for user alice: 1 items
2025/12/03 13:01:12 "GET http://localhost:8082/api/cart HTTP/1.1" from [::1]:48324 - 200 95B in 5.676215ms
2025/12/03 13:01:15 "GET http://localhost:8082/api/products HTTP/1.1" from [::1]:48324 - 200 1026B in 251.337µs
2025/12/03 13:01:17 ✓ Authenticated user: alice
2025/12/03 13:01:17 AddToCart: user=alice, product=5, quantity=1
2025/12/03 13:01:17 INFO Handling invocation method=UserSession/AddItem invocationID=inv_1l3Hc716hrBy3WCZuXVGT5XY5VCTYbBOH7
2025/12/03 13:01:17 INFO Adding item to cart method=UserSession/AddItem invocationID=inv_1l3Hc716hrBy3WCZuXVGT5XY5VCTYbBOH7 user_id=alice product_id=5
2025/12/03 13:01:17 INFO Cart updated method=UserSession/AddItem invocationID=inv_1l3Hc716hrBy3WCZuXVGT5XY5VCTYbBOH7 user_id=alice total_items=2
2025/12/03 13:01:17 INFO Invocation completed successfully method=UserSession/AddItem invocationID=inv_1l3Hc716hrBy3WCZuXVGT5XY5VCTYbBOH7
2025/12/03 13:01:17 Successfully added item to cart for user alice
2025/12/03 13:01:17 "POST http://localhost:8082/api/cart/add HTTP/1.1" from [::1]:48324 - 200 48B in 10.052191ms
2025/12/03 13:01:17 ✓ Authenticated user: alice
2025/12/03 13:01:17 GetCart: user=alice
2025/12/03 13:01:17 INFO Handling invocation method=UserSession/GetBasket invocationID=inv_1l3Hc716hrBy2eZxPy6pm8SuqsHdW85JyV
2025/12/03 13:01:17 INFO Fetching cart method=UserSession/GetBasket invocationID=inv_1l3Hc716hrBy2eZxPy6pm8SuqsHdW85JyV user_id=alice
2025/12/03 13:01:17 INFO Invocation completed successfully method=UserSession/GetBasket invocationID=inv_1l3Hc716hrBy2eZxPy6pm8SuqsHdW85JyV
2025/12/03 13:01:17 Successfully fetched cart for user alice: 2 items
2025/12/03 13:01:17 "GET http://localhost:8082/api/cart HTTP/1.1" from [::1]:48324 - 200 184B in 5.570833ms
2025/12/03 13:01:20 "GET http://localhost:8082/api/products HTTP/1.1" from [::1]:48324 - 200 1026B in 214.719µs
2025/12/03 13:01:22 ✓ Authenticated user: alice
2025/12/03 13:01:22 AddToCart: user=alice, product=3, quantity=1
2025/12/03 13:01:22 INFO Handling invocation method=UserSession/AddItem invocationID=inv_1l3Hc716hrBy1g6rmrnoraSJzB7qEIuS9H
2025/12/03 13:01:22 INFO Adding item to cart method=UserSession/AddItem invocationID=inv_1l3Hc716hrBy1g6rmrnoraSJzB7qEIuS9H user_id=alice product_id=3
2025/12/03 13:01:22 INFO Cart updated method=UserSession/AddItem invocationID=inv_1l3Hc716hrBy1g6rmrnoraSJzB7qEIuS9H user_id=alice total_items=3
2025/12/03 13:01:22 INFO Invocation completed successfully method=UserSession/AddItem invocationID=inv_1l3Hc716hrBy1g6rmrnoraSJzB7qEIuS9H
2025/12/03 13:01:22 Successfully added item to cart for user alice
2025/12/03 13:01:22 "POST http://localhost:8082/api/cart/add HTTP/1.1" from [::1]:48324 - 200 48B in 10.092397ms
2025/12/03 13:01:22 ✓ Authenticated user: alice
2025/12/03 13:01:22 GetCart: user=alice
2025/12/03 13:01:22 INFO Handling invocation method=UserSession/GetBasket invocationID=inv_1l3Hc716hrBy0DIM4jX0cA8P0mISPqKSo9
2025/12/03 13:01:22 INFO Fetching cart method=UserSession/GetBasket invocationID=inv_1l3Hc716hrBy0DIM4jX0cA8P0mISPqKSo9 user_id=alice
2025/12/03 13:01:22 INFO Invocation completed successfully method=UserSession/GetBasket invocationID=inv_1l3Hc716hrBy0DIM4jX0cA8P0mISPqKSo9
2025/12/03 13:01:22 Successfully fetched cart for user alice: 3 items
2025/12/03 13:01:22 "GET http://localhost:8082/api/cart HTTP/1.1" from [::1]:48324 - 200 273B in 5.810946ms
2025/12/03 13:01:34 ✓ Authenticated user: alice
2025/12/03 13:01:34 "GET http://localhost:8082/api/orders HTTP/1.1" from [::1]:48324 - 200 3B in 251.064µs
2025/12/03 13:01:36 "GET http://localhost:8082/api/products HTTP/1.1" from [::1]:48324 - 200 1026B in 224.534µs
2025/12/03 13:01:38 ✓ Authenticated user: alice
2025/12/03 13:01:38 GetCart: user=alice
2025/12/03 13:01:38 INFO Handling invocation method=UserSession/GetBasket invocationID=inv_1l3Hc716hrBy3hg45cDD7Gmsfq2tyAnXvb
2025/12/03 13:01:38 INFO Fetching cart method=UserSession/GetBasket invocationID=inv_1l3Hc716hrBy3hg45cDD7Gmsfq2tyAnXvb user_id=alice
2025/12/03 13:01:38 INFO Invocation completed successfully method=UserSession/GetBasket invocationID=inv_1l3Hc716hrBy3hg45cDD7Gmsfq2tyAnXvb
2025/12/03 13:01:38 Successfully fetched cart for user alice: 3 items
2025/12/03 13:01:38 "GET http://localhost:8082/api/cart HTTP/1.1" from [::1]:48324 - 200 273B in 296.437599ms
2025/12/03 13:01:41 "GET http://localhost:8082/api/products HTTP/1.1" from [::1]:48324 - 200 1026B in 175.924µs
2025/12/03 13:01:42 ✓ Authenticated user: alice
2025/12/03 13:01:42 GetCart: user=alice
2025/12/03 13:01:42 INFO Handling invocation method=UserSession/GetBasket invocationID=inv_1l3Hc716hrBy01xwnDs9gZHwAFqCtmOvQZ
2025/12/03 13:01:42 INFO Fetching cart method=UserSession/GetBasket invocationID=inv_1l3Hc716hrBy01xwnDs9gZHwAFqCtmOvQZ user_id=alice
2025/12/03 13:01:42 INFO Invocation completed successfully method=UserSession/GetBasket invocationID=inv_1l3Hc716hrBy01xwnDs9gZHwAFqCtmOvQZ
2025/12/03 13:01:42 Successfully fetched cart for user alice: 3 items
2025/12/03 13:01:42 "GET http://localhost:8082/api/cart HTTP/1.1" from [::1]:48324 - 200 273B in 8.708166ms
2025/12/03 13:01:44 ✓ Authenticated user: alice
2025/12/03 13:01:44 "POST http://localhost:8082/api/checkout HTTP/1.1" from [::1]:48324 - 202 119B in 4.774079ms
2025/12/03 13:01:44 INFO Handling invocation method=UserSession/Checkout invocationID=inv_1l3Hc716hrBy7C3RhCblD3acAVQardxcAN
2025/12/03 13:01:44 INFO User initiating checkout method=UserSession/Checkout invocationID=inv_1l3Hc716hrBy7C3RhCblD3acAVQardxcAN user_id=alice order_id=order-alice-1764738104158
2025/12/03 13:01:44 INFO Notifying external Payment Gateway method=UserSession/Checkout invocationID=inv_1l3Hc716hrBy7C3RhCblD3acAVQardxcAN awakeable_id=sign_1_HkLWEhiS_UBmuKWe2BcWfS109btRiv6AAAAEQ amount_cents=29500
2025/12/03 13:01:44 INFO Awaiting payment confirmation method=UserSession/Checkout invocationID=inv_1l3Hc716hrBy7C3RhCblD3acAVQardxcAN order_id=order-alice-1764738104158 awakeable_id=sign_1_HkLWEhiS_UBmuKWe2BcWfS109btRiv6AAAAEQ
2025/12/03 13:02:44 INFO Suspending invocation method=UserSession/Checkout invocationID=inv_1l3Hc716hrBy7C3RhCblD3acAVQardxcAN
2025/12/03 13:02:53 Received payment callback for awakeable sign_1_HkLWEhiS_UBmuKWe2BcWfS109btRiv6AAAAEQ, status success
2025/12/03 13:02:53 Successfully resolved awakeable sign_1_HkLWEhiS_UBmuKWe2BcWfS109btRiv6AAAAEQ with payment result
2025/12/03 13:02:53 "POST http://localhost:8082/api/payment/callback HTTP/1.1" from [::1]:46312 - 200 121B in 2.165636ms
2025/12/03 13:02:53 INFO Handling invocation method=UserSession/Checkout invocationID=inv_1l3Hc716hrBy7C3RhCblD3acAVQardxcAN
2025/12/03 13:02:53 INFO Awaiting payment confirmation method=UserSession/Checkout invocationID=inv_1l3Hc716hrBy7C3RhCblD3acAVQardxcAN order_id=order-alice-1764738104158 awakeable_id=sign_1_HkLWEhiS_UBmuKWe2BcWfS109btRiv6AAAAEQ
2025/12/03 13:02:53 INFO Payment successful method=UserSession/Checkout invocationID=inv_1l3Hc716hrBy7C3RhCblD3acAVQardxcAN order_id=order-alice-1764738104158 transaction_id=txn-1764738104167
2025/12/03 13:02:53 INFO Marked checkout as executed method=UserSession/Checkout invocationID=inv_1l3Hc716hrBy7C3RhCblD3acAVQardxcAN order_id=order-alice-1764738104158
2025/12/03 13:02:53 INFO Session state cleared method=UserSession/Checkout invocationID=inv_1l3Hc716hrBy7C3RhCblD3acAVQardxcAN
2025/12/03 13:02:53 INFO Workflow launched method=UserSession/Checkout invocationID=inv_1l3Hc716hrBy7C3RhCblD3acAVQardxcAN order_id=order-alice-1764738104158
2025/12/03 13:02:53 INFO Invocation completed successfully method=UserSession/Checkout invocationID=inv_1l3Hc716hrBy7C3RhCblD3acAVQardxcAN
2025/12/03 13:02:53 INFO Handling invocation method=OrderFulfillmentWorkflow/Run invocationID=inv_17JErH98oMwF4W3QqzAjqCne0EEEEbDp3c
2025/12/03 13:02:53 INFO Workflow started method=OrderFulfillmentWorkflow/Run invocationID=inv_17JErH98oMwF4W3QqzAjqCne0EEEEbDp3c order_id=order-alice-1764738104158
2025/12/03 13:02:53 INFO Processing order with authenticated user method=OrderFulfillmentWorkflow/Run invocationID=inv_17JErH98oMwF4W3QqzAjqCne0EEEEbDp3c user_id=alice order_id=order-alice-1764738104158
2025/12/03 13:02:53 INFO Waiting for admin approval method=OrderFulfillmentWorkflow/Run invocationID=inv_17JErH98oMwF4W3QqzAjqCne0EEEEbDp3c order_id=order-alice-1764738104158
2025/12/03 13:03:01 "GET http://localhost:8082/admin HTTP/1.1" from [::1]:48324 - 304 0B in 75.403µs
2025/12/03 13:03:01 "GET http://localhost:8082/stream/notifications HTTP/1.1" from [::1]:48284 - 000 176B in 2m1.462438787s
2025/12/03 13:03:01 "GET http://localhost:8082/stream/notifications HTTP/1.1" from [::1]:48318 - 000 150B in 1m58.934271845s
2025/12/03 13:03:01 "GET http://localhost:8082/static/css/reset.css HTTP/1.1" from [::1]:48324 - 304 0B in 75.122µs
2025/12/03 13:03:01 "GET http://localhost:8082/static/css/variables.css HTTP/1.1" from [::1]:48324 - 304 0B in 64.423µs
2025/12/03 13:03:01 "GET http://localhost:8082/static/js/main.js HTTP/1.1" from [::1]:40014 - 304 0B in 85.66µs
2025/12/03 13:03:01 "GET http://localhost:8082/static/css/layout.css HTTP/1.1" from [::1]:40004 - 304 0B in 59.594µs
2025/12/03 13:03:01 "GET http://localhost:8082/static/css/components.css HTTP/1.1" from [::1]:48324 - 304 0B in 36.034µs
2025/12/03 13:03:01 "GET http://localhost:8082/.well-known/appspecific/com.chrome.devtools.json HTTP/1.1" from [::1]:40018 - 404 19B in 7.573µs
2025/12/03 13:03:04 "GET http://localhost:8082/stream/notifications HTTP/1.1" from [::1]:40018 - 000 72B in 2.984829449s
2025/12/03 13:03:04 "GET http://localhost:8082/.well-known/appspecific/com.chrome.devtools.json HTTP/1.1" from [::1]:48324 - 404 19B in 12.312µs
2025/12/03 13:03:33 INFO Handling invocation method=OrderFulfillmentWorkflow/OnApprove invocationID=inv_17JErH98oMwF59BRT5SKeRAjycSNRT9Qid
2025/12/03 13:03:33 INFO Shared context handler received approval signal method=OrderFulfillmentWorkflow/OnApprove invocationID=inv_17JErH98oMwF59BRT5SKeRAjycSNRT9Qid order_id=order-alice-1764738104158 approved=true
2025/12/03 13:03:33 INFO Invocation completed successfully method=OrderFulfillmentWorkflow/OnApprove invocationID=inv_17JErH98oMwF59BRT5SKeRAjycSNRT9Qid
2025/12/03 13:03:33 INFO Admin approved order method=OrderFulfillmentWorkflow/Run invocationID=inv_17JErH98oMwF4W3QqzAjqCne0EEEEbDp3c order_id=order-alice-1764738104158
2025/12/03 13:03:33 "POST http://localhost:8082/api/workflow/order-alice-1764738104158/approve HTTP/1.1" from [::1]:40004 - 200 76B in 9.436519ms
2025/12/03 13:03:33 INFO Handling invocation method=ShippingService/InitiateShipment invocationID=inv_18xEZgJpE8wG4STGvqEJ9BTHBeJrLUtCuJ
2025/12/03 13:03:33 INFO ShippingService received request method=ShippingService/InitiateShipment invocationID=inv_18xEZgJpE8wG4STGvqEJ9BTHBeJrLUtCuJ order_id=order-alice-1764738104158
2025/12/03 13:03:33 INFO Successfully registered shipment method=ShippingService/InitiateShipment invocationID=inv_18xEZgJpE8wG4STGvqEJ9BTHBeJrLUtCuJ order_id=order-alice-1764738104158
2025/12/03 13:03:33 INFO Invocation completed successfully method=ShippingService/InitiateShipment invocationID=inv_18xEZgJpE8wG4STGvqEJ9BTHBeJrLUtCuJ
2025/12/03 13:03:33 INFO Shipping initiated successfully method=OrderFulfillmentWorkflow/Run invocationID=inv_17JErH98oMwF4W3QqzAjqCne0EEEEbDp3c order_id=order-alice-1764738104158
2025/12/03 13:03:33 INFO Waiting for delivery confirmation method=OrderFulfillmentWorkflow/Run invocationID=inv_17JErH98oMwF4W3QqzAjqCne0EEEEbDp3c estimated_seconds=5
2025/12/03 13:03:38 INFO Delivery timer expired, order assumed delivered method=OrderFulfillmentWorkflow/Run invocationID=inv_17JErH98oMwF4W3QqzAjqCne0EEEEbDp3c order_id=order-alice-1764738104158
2025/12/03 13:03:38 INFO Order fulfillment complete method=OrderFulfillmentWorkflow/Run invocationID=inv_17JErH98oMwF4W3QqzAjqCne0EEEEbDp3c order_id=order-alice-1764738104158
2025/12/03 13:03:38 INFO COMPENSATION: Triggering shipping cancellation method=OrderFulfillmentWorkflow/Run invocationID=inv_17JErH98oMwF4W3QqzAjqCne0EEEEbDp3c order_id=order-alice-1764738104158
2025/12/03 13:03:38 INFO COMPENSATION: Inventory reservation released method=OrderFulfillmentWorkflow/Run invocationID=inv_17JErH98oMwF4W3QqzAjqCne0EEEEbDp3c order_id=order-alice-1764738104158
2025/12/03 13:03:38 INFO Invocation completed successfully method=OrderFulfillmentWorkflow/Run invocationID=inv_17JErH98oMwF4W3QqzAjqCne0EEEEbDp3c
2025/12/03 13:03:38 INFO Handling invocation method=ShippingService/CancelShipment invocationID=inv_13drYZcbLJT60UDBcebwcILKe7jWuCyfSx
2025/12/03 13:03:38 INFO COMPENSATION: Cancelling shipment method=ShippingService/CancelShipment invocationID=inv_13drYZcbLJT60UDBcebwcILKe7jWuCyfSx order_id=order-alice-1764738104158
2025/12/03 13:03:38 INFO Invocation completed successfully method=ShippingService/CancelShipment invocationID=inv_13drYZcbLJT60UDBcebwcILKe7jWuCyfSx
Question:
Based on logs above, why was there a Triggering shipping cancellation?
Reply:
I found the issue with the unexpected shipping cancellation. The compensation logic was running unconditionally at the end of the function, regardless of success or failure.
I have updated backend/services/order_workflow.go to only trigger compensations if the workflow returns an error.
Action Required: Please restart your backend server again to apply this fix. After restarting, new orders should complete without triggering the cancellation log.
Test:
curl -X POST http://localhost:8082/api/payment/callback \
-H "Content-Type: application/json" \
-d '{"awakeable_id": "sign_1_HkLWEhiS_UBmuKpDoPVq9Yxyo3DwdoHAAAAEQ", "transaction_id": "txn-1764739321483", "amount": 10000, "status": "success"}'