Skip to content

Fix 500 error when Commit action is missing

Vasilii Iakliushin requested to merge fix_500_error_for_empty_actions into master

What does this MR do and why?

Sentry error: https://sentry.gitlab.net/gitlab/gitlabcom/issues/3402967

Problem

It's possible to provide an empty value for Commit action. It leads to 500 error.

Solution

Use allow_blank: false validation.

How to verify

  1. Replace <PERSONAL_TOKEN> with your token and execute in console

    curl --header "PRIVATE-TOKEN: <PERSONAL_TOKEN>" --header "Content-Type: application/json" http://127.0.0.1:3000/api/v4/projects/1/repository/commits  -X POST -d '{"branch": "master", "commit_message": "Test", "actions": [{ "action": null, "file_path": "test" }]}'
  2. You should see 400 error instead of 500 error.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Vasilii Iakliushin

Merge request reports

Loading