[go: up one dir, main page]

Skip to content

Repository File API: Updating a file using PUT does not behave as expected

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Summary

When updating a file via the Repository API (PUT) and the content is the same, it should return HTTP 400 (Bad Request). But it returns HTTP 200 (OK).

Steps to reproduce

Make a curl call to any file you have access, as described in the documentation. e.g.

curl --request PUT --header 'PRIVATE-TOKEN: <your_access_token>' \ --header "Content-Type: application/json" \ --data '{"branch": "master", "author_email": "author@example.com", "author_name": "Firstname Lastname", "content": "some content", "commit_message": "update file"}' \ "https://gitlab.example.com/api/v4/projects/13083/repository/files/app%2Fproject%2Erb"

Content is the same as in the existing file. Response is 200.

What is the current bug behavior?

When requesting to update the file with same content (empty commit) 200 is returned and the empty commit is visible in the git history

What is the expected correct behavior?

As described in the documentation a 400 Bad Request should be returned, and no commit should be made in history.

Output of checks

This bug happens on GitLab.com

Edited by 🤖 GitLab Bot 🤖