Skip to content

refactor: use centralized error handling in branch protection controller - #747

Open
vaaibhavkaushik wants to merge 2 commits into
Ankita15k:mainfrom
vaaibhavkaushik:feature-standard-error-handling-746
Open

refactor: use centralized error handling in branch protection controller#747
vaaibhavkaushik wants to merge 2 commits into
Ankita15k:mainfrom
vaaibhavkaushik:feature-standard-error-handling-746

Conversation

@vaaibhavkaushik

@vaaibhavkaushik vaaibhavkaushik commented Jul 11, 2026

Copy link
Copy Markdown

Summary

Refactors the Branch Protection controller to use GitNest's existing centralized error-handling pipeline.

Changes

  • Replaced direct inline 500 responses with next(error).
  • Converted repository-not-found cases to AppError with status 404.
  • Converted repository ownership failures to AppError with status 403.
  • Converted branch-protection service validation failures to standardized 422 errors.
  • Preserved existing successful response payloads.
  • Preserved branch-protection audit event emission.
  • Removed duplicated controller-level error-response logic.

Validation

  • node --check backend/src/controllers/branchProtection.controller.js
  • git diff --check

The full repository test suite currently contains unrelated pre-existing failures involving missing validators, broken exports, rate-limit tests, and other modules outside this PR's scope.

Closes #746

Contributing under GSSoC'26.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your first Pull Request to GitNest! 🚀 We will review your changes soon. Please make sure you've linked the related issues.

@Ankita15k

Copy link
Copy Markdown
Owner

@vaaibhavkaushik, please wait until an issue has been assigned to you before opening a PR. Pull requests for unassigned issues will not be considered for review.

Thank you for your understanding and cooperation! 🙌🏻

@vaaibhavkaushik

Copy link
Copy Markdown
Author

@vaaibhavkaushik, please wait until an issue has been assigned to you before opening a PR. Pull requests for unassigned issues will not be considered for review.

Thank you for your understanding and cooperation! 🙌🏻

Thank you for the clarification, @Ankita15k. I understand and apologize for opening the PR before the issue was assigned.

I had already completed the implementation and wanted to contribute, but I'll make sure to wait for an official assignment before opening any future PRs.

If possible, I would be grateful if you could kindly review this PR once, as the changes are already implemented and follow the project's existing patterns. If it cannot be considered due to the repository policy, I completely understand and will follow the assignment process for all future contributions.

Thank you for your time and guidance! 🙏

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.

FEATURE: Improved error handling

2 participants