mirror of
https://github.com/codeflash-ai/codeflash-internal.git
synced 2026-05-04 18:25:18 +00:00
## Summary
- Fix race condition in `ensureLabelExists` where concurrent requests
both get a 404, then both try to create the label, causing an
"already_exists" validation error
- Add `isLabelAlreadyExistsError` helper function to properly detect
GitHub's 422 validation error for duplicate labels
- Change error handling from throwing to logging to Sentry, preventing
the entire PR creation flow from failing due to label issues
- Update tests to verify new Sentry logging behavior and race condition
handling
## Problem
When multiple concurrent requests call `ensureLabelExists`:
1. Both check if label exists → both get 404
2. Both try to create the label
3. First succeeds, second fails with
`{"resource":"Label","code":"already_exists","field":"name"}`
4. This error was thrown and caused the entire suggest-pr-changes flow
to fail
## Solution
- Catch the `already_exists` error during label creation and silently
ignore it (label exists, which is the desired state)
- Log other errors to Sentry instead of throwing, so label issues don't
block PR creation
FIxes CF-1017
|
||
|---|---|---|
| .. | ||
| create-pr-from-diffcontents.unit.test.ts | ||
| github-utils.unit.test.ts | ||
| slack_util.unit.test.ts | ||