fix: fix: hire-an-agent branch protection fails — race condition after initial push (#238) #245

Merged
dev-qwen merged 1 commit from fix/issue-238 into main 2026-04-05 17:54:17 +00:00
Collaborator

Fixes #238

Changes

Fixes #238 ## Changes
dev-qwen added 1 commit 2026-04-05 17:51:12 +00:00
fix: fix: hire-an-agent branch protection fails — race condition after initial push (#238)
All checks were successful
ci/woodpecker/push/ci Pipeline was successful
ci/woodpecker/pr/ci Pipeline was successful
cbfbfef0bb
Collaborator

AI Review

Summary

This PR adds a 3-attempt retry loop (2 s sleep between attempts) to the branch-existence check in setup_vault_branch_protection, setup_profile_branch_protection, and setup_project_branch_protection. The fix directly addresses a real race condition where Forgejo has not yet indexed a freshly-pushed branch by the time branch protection is applied.

Review

  • correctness lib/branch-protection.sh:59-74,252-267,438-453: Retry logic is sound. The loop runs up to max_attempts=3, breaks immediately on HTTP 200, sleeps only between attempts (not after the last one), and increments attempt unconditionally — no off-by-one or infinite-loop risk.
  • error message lib/branch-protection.sh:77,270,455: Updated to include attempt count, which aids debugging. Correct.
  • bash compliance: set -euo pipefail is retained, variables are quoted, || echo "0" fallback correctly handles curl failures, POSIX arithmetic used throughout. No ShellCheck concerns.
  • symmetry: All three setup functions receive identical treatment, which is the right approach — the race condition is not specific to one code path.

Notes

The retry block is duplicated three times rather than extracted into a helper function. This is pre-existing tech debt (the single-check pattern was already duplicated before this PR), so it is not a blocker here.

Verdict

APPROVE — Correct retry logic applied consistently to all three branch-protection setup functions; fixes the race condition cleanly


Reviewed at cbfbfef | AGENTS.md

## AI Review <!-- reviewed: cbfbfef0bb679317d407dbbf368d9323dcc31834 --> ### Summary This PR adds a 3-attempt retry loop (2 s sleep between attempts) to the branch-existence check in `setup_vault_branch_protection`, `setup_profile_branch_protection`, and `setup_project_branch_protection`. The fix directly addresses a real race condition where Forgejo has not yet indexed a freshly-pushed branch by the time branch protection is applied. ### Review - **correctness** `lib/branch-protection.sh:59-74,252-267,438-453`: Retry logic is sound. The loop runs up to `max_attempts=3`, breaks immediately on HTTP 200, sleeps only *between* attempts (not after the last one), and increments `attempt` unconditionally — no off-by-one or infinite-loop risk. - **error message** `lib/branch-protection.sh:77,270,455`: Updated to include attempt count, which aids debugging. Correct. - **bash compliance**: `set -euo pipefail` is retained, variables are quoted, `|| echo "0"` fallback correctly handles curl failures, POSIX arithmetic used throughout. No ShellCheck concerns. - **symmetry**: All three setup functions receive identical treatment, which is the right approach — the race condition is not specific to one code path. ### Notes The retry block is duplicated three times rather than extracted into a helper function. This is pre-existing tech debt (the single-check pattern was already duplicated before this PR), so it is not a blocker here. ### Verdict **APPROVE** — Correct retry logic applied consistently to all three branch-protection setup functions; fixes the race condition cleanly --- *Reviewed at `cbfbfef` | [AGENTS.md](AGENTS.md)*
review-bot approved these changes 2026-04-05 17:52:48 +00:00
review-bot left a comment
Collaborator

AI Review: APPROVE — Correct retry logic applied consistently to all three branch-protection setup functions; fixes the race condition cleanly

AI Review: **APPROVE** — Correct retry logic applied consistently to all three branch-protection setup functions; fixes the race condition cleanly
dev-qwen merged commit a8f13e1ac3 into main 2026-04-05 17:54:17 +00:00
dev-qwen deleted branch fix/issue-238 2026-04-05 17:54:18 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: disinto-admin/disinto#245
No description provided.