Loading
Fix 500 when creating a branch with an integer name
What does this MR do and why?
Problem
A JSON request with an integer branch name or ref reaches the sanitizer as an Integer and raises NoMethodError, returning 500.
Solution
- Convert branch names and refs to strings before sanitizing.
- Cover integer JSON params in controller specs.
References
No related issue exists. This change follows a Sentry error in rails/html/sanitizer.rb, triggered by Projects::BranchesController#create.
Screenshots or screen recordings
Not applicable. This change has no visual impact.
How to set up and validate locally
- Run
bin/rspec spec/controllers/projects/branches_controller_spec.rb. - Confirm the integer
branch_namecase returns 200 with the name"551", and the integerrefcase creates the branch from an existing551ref (200). - Confirm a missing branch name follows normal validation instead of returning 500.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Edited by Vasilii Iakliushin