ReviewOS

also looking at this

stacks/buddy

fix(dashboard): fail closed when the dashboard lookup errors

#1452
Merged glennmichael123 wants to merge fix/dashboard-duplicate-on-transient-failure into main
2 files +39 -4
src/buddy.tsmodified+15-2
Changes to src/buddy.ts
@@ -3685,8 +3685,21 @@ export class Buddy {
36853685 return null
36863686 }
36873687 catch (error) {
3688 this.logger.warn(`Failed to search for existing dashboard: ${error}`)
3689 return null
3688 // "Found nothing" and "the lookup failed" must not collapse to the same
3689 // value. The caller treats null as "no dashboard exists" and creates one,
3690 // so a transient 5xx, timeout or secondary rate-limit on getIssues() would
3691 // open a duplicate dashboard and still exit 0 - permanent damage from a
3692 // momentary failure.
3693 //
3694 // Both call sites reach this: the initial lookup and the pre-create race
3695 // check. The race check in particular was no protection at all while it
3696 // failed open, because whatever broke the first lookup is usually still
3697 // broken a moment later.
3698 //
3699 // A failed run is recoverable - the next scheduled run retries. A duplicate
3700 // dashboard is not: someone has to notice it and close it by hand.
3701 this.logger.error(`Failed to search for existing dashboard: ${error}`)
3702 throw error
36903703 }
36913704 }
36923705}