also looking at this
fix(dashboard): fail closed when the dashboard lookup errors
#1452
2 files
+39
-4
| @@ -670,10 +670,32 @@ describe('buddy orchestration', () => { | ||
| 670 | 670 | expect(await findDashboard(provider)).toBeNull() |
| 671 | 671 | }) |
| 672 | 672 | |
| 673 | it('failure case - a getIssues failure degrades to null instead of throwing', async () => { | |
| 673 | // Absence and failure must stay distinguishable. The caller reads null as | |
| 674 | // "no dashboard exists" and creates one, so degrading a transient failure to | |
| 675 | // null turned a momentary 5xx into a permanent duplicate dashboard while the | |
| 676 | // run still exited 0. Failing the run is recoverable - the next scheduled run | |
| 677 | // retries; a duplicate dashboard has to be closed by hand. | |
| 678 | it('failure case - a getIssues failure rejects instead of reporting absence', async () => { | |
| 674 | 679 | const provider = { getIssues: mock(() => Promise.reject(new Error('api down'))) } |
| 675 | 680 | |
| 676 | expect(await findDashboard(provider)).toBeNull() | |
| 681 | await expect(findDashboard(provider)).rejects.toThrow('api down') | |
| 682 | }) | |
| 683 | ||
| 684 | it('failure case - the pre-create race check rejects on the same failure', async () => { | |
| 685 | // The race check calls this same helper, so while it failed open it was no | |
| 686 | // protection at all: whatever broke the first lookup is usually still | |
| 687 | // broken a moment later. | |
| 688 | const provider = { getIssues: mock(() => Promise.reject(new Error('secondary rate limit'))) } | |
| 689 | ||
| 690 | await expect(findDashboard(provider)).rejects.toThrow('secondary rate limit') | |
| 691 | }) | |
| 692 | ||
| 693 | it('failure case - a configured issueNumber lookup rejects rather than reporting it missing', async () => { | |
| 694 | // This path calls getIssues too, so it failed open in the same way - and | |
| 695 | // "configured dashboard is missing" is exactly what triggers a create. | |
| 696 | const provider = { getIssues: mock(() => Promise.reject(new Error('api down'))) } | |
| 697 | ||
| 698 | await expect(findDashboard(provider, 1911)).rejects.toThrow('api down') | |
| 677 | 699 | }) |
| 678 | 700 | |
| 679 | 701 | it('success case - honors an explicit issueNumber even without marker or labels', async () => { |