Skip to content

fix(backend): abort GitLab sync on non-404 API errors to prevent repo deletion#1039

Merged
brendan-kellam merged 2 commits intomainfrom
brendan/fix-SOU-727
Mar 24, 2026
Merged

fix(backend): abort GitLab sync on non-404 API errors to prevent repo deletion#1039
brendan-kellam merged 2 commits intomainfrom
brendan/fix-SOU-727

Conversation

@brendan-kellam
Copy link
Contributor

@brendan-kellam brendan-kellam commented Mar 24, 2026

Summary

  • GitLab API errors (e.g. 500) were previously converted to warnings, allowing the sync to continue with a partial repo list
  • The database reconciliation then deleted all RepoToConnection records and only re-created repos from the partial list, effectively orphaning repos from the failed group/user/project
  • Now only 404 errors are treated as warnings (resource not found or no access); all other errors abort the sync so the database is left untouched — matching the existing behavior in github.ts

Fixes #1029

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Fixed GitLab sync to preserve repositories when the API encounters non-404 errors. The sync now correctly handles only "not found" scenarios without unexpected repository deletion.

… deletion

Previously, any HTTP error from the GitLab API (including 500s) was
converted to a warning and the sync continued with a partial repo list.
This caused the database reconciliation to delete repos from the failed
group/user/project. Now only 404 errors are treated as warnings (resource
not found or no access); all other errors abort the sync so the database
is left untouched.

Fixes #1029

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions

This comment has been minimized.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 24, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c6ddd68a-da1d-43f7-9a45-18639f37c2e8

📥 Commits

Reviewing files that changed from the base of the PR and between bdab4b7 and c5c1734.

📒 Files selected for processing (2)
  • CHANGELOG.md
  • packages/backend/src/gitlab.ts

Walkthrough

Fixed GitLab API error handling to prevent unintended repository deletion when non-404 errors (e.g., HTTP 500) occur during group/user/project lookups. The code now distinguishes between 404 errors (treated as warnings) and other errors (rethrown), preventing silent fallthrough that caused data loss.

Changes

Cohort / File(s) Summary
Changelog Documentation
CHANGELOG.md
Added entry documenting the fix that prevents repository deletion when GitLab API returns non-404 errors during sync operations.
Error Handling Logic
packages/backend/src/gitlab.ts
Refined GitLab API error handling in getGitLabReposFromConfig to specifically check for 404 status and return a warning result with descriptive messages (e.g., "Group not found or no access"). Non-404 errors are rethrown instead of being silently ignored, preventing unintended repository deletion during API failures.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch brendan/fix-SOU-727

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@brendan-kellam brendan-kellam merged commit b0b0c3c into main Mar 24, 2026
6 checks passed
@brendan-kellam brendan-kellam deleted the brendan/fix-SOU-727 branch March 24, 2026 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deleted repositories after Gitlab API returning HTTP 500

1 participant