Update of existing file with identical content returns 200 and not 400 as expected.

Summary

Update of existing file with identical content returns 200 and not 400 as expected.

Steps to reproduce

Using any project with a private token with API scope.

% curl -i --request POST --header 'PRIVATE-TOKEN: ...' --header 'Content-Type: application/json' --data '{"branch": "master", "content": "{}", "commit_message": "new file"}' http://host-name:port/api/v4/projects/project-id/repository/files/any-name.json

% curl -i --request PUT  --header 'PRIVATE-TOKEN: ...' --header 'Content-Type: application/json' --data '{"branch": "master", "content": "{}", "commit_message": "test"}' http://host-name:port/api/v4/projects/project-id/repository/files/any-name.json

% curl -i --request PUT  --header 'PRIVATE-TOKEN: ...' --header 'Content-Type: application/json' --data '{"branch": "master", "content": "{}", "commit_message": "test"}' http://host-name:port/api/v4/projects/project-id/repository/files/any-name.json

Example Project

What is the current bug behavior?

The second PUT returns a status code of 200, creates a commit for the named file. The commit shows zero changed files.

What is the expected correct behavior?

The second PUT is expected to return a 400, as described in docs

If the commit fails for any reason we return a 400 error with a non-specific error message. Possible causes for a failed commit include: - the file_path contained /../ (attempted directory traversal); - the new file contents were identical to the current file contents, ... ​ at URL https://docs.gitlab.com/ee/api/repository_files.html#update-existing-file-in-repository.

Relevant logs and/or screenshots

Output of checks

Results of GitLab environment info

Results of GitLab application Check

Possible fixes

Assignee Loading
Time tracking Loading