Commit 9df6dff
committed
fix(folders): close workflow-folder restore lock race, align restore error codes
Three related restore-path bugs found by Greptile/Cursor this round:
1. performRestoreFolder (workflow folders) read the folder's own `locked`
flag BEFORE opening the restore transaction. A folder locked in the
window between that read and the transaction's write could still be
resurrected and mutated. Restructured to match performRestoreResourceFolder
(kb/table): the not_found/not_archived/locked checks and the restore
writes all now happen inside one transaction.
2. Restoring an already-active (non-archived) workflow folder silently
returned 200/success with zero restoredItems, while the same request for
knowledge base, table, and file folders correctly returns a 400
validation error. Now returns errorCode: 'validation' -> 400, consistent
with the other three resource types.
3. performRestoreFileFolder's 'Folder not found' case returned no
errorCode, so it fell through the route's default and mapped to 400
instead of 404 (workflow/kb/table restores already mapped this
correctly). Added errorCode: 'not_found' to that branch, plus
errorCode: 'conflict'/'validation'/'internal' to the sibling branches
for consistency with performCreateFileFolder's existing pattern, and
stopped leaking the raw internal error message to the client on an
unexpected failure.1 parent cdd5045 commit 9df6dff
2 files changed
Lines changed: 47 additions & 30 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
311 | 311 | | |
312 | 312 | | |
313 | 313 | | |
| 314 | + | |
314 | 315 | | |
315 | 316 | | |
316 | 317 | | |
317 | | - | |
318 | | - | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
319 | 323 | | |
320 | 324 | | |
321 | | - | |
| 325 | + | |
322 | 326 | | |
323 | 327 | | |
324 | 328 | | |
| |||
Lines changed: 40 additions & 27 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
474 | 474 | | |
475 | 475 | | |
476 | 476 | | |
477 | | - | |
478 | | - | |
479 | | - | |
480 | | - | |
481 | | - | |
482 | | - | |
483 | | - | |
484 | | - | |
485 | | - | |
486 | | - | |
487 | | - | |
488 | | - | |
489 | | - | |
490 | | - | |
491 | | - | |
492 | | - | |
493 | | - | |
494 | | - | |
495 | | - | |
496 | 477 | | |
497 | 478 | | |
498 | 479 | | |
499 | 480 | | |
500 | 481 | | |
501 | 482 | | |
502 | | - | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
503 | 501 | | |
504 | 502 | | |
505 | 503 | | |
| |||
520 | 518 | | |
521 | 519 | | |
522 | 520 | | |
523 | | - | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
524 | 528 | | |
525 | 529 | | |
526 | | - | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
527 | 540 | | |
528 | 541 | | |
529 | 542 | | |
530 | 543 | | |
531 | 544 | | |
532 | 545 | | |
533 | 546 | | |
534 | | - | |
535 | | - | |
| 547 | + | |
| 548 | + | |
536 | 549 | | |
537 | 550 | | |
538 | | - | |
539 | | - | |
| 551 | + | |
| 552 | + | |
540 | 553 | | |
541 | 554 | | |
542 | 555 | | |
543 | 556 | | |
544 | | - | |
| 557 | + | |
545 | 558 | | |
0 commit comments