[API] Can't create empty-commit via API because actions is required

Hello,

Ever since some validation was added by 5413d2b38ae6 ("Apply requestBodyUploader to commit creation endpoints") Dec 8th, the API started responding with "400 Bad request - actions is required", when given an empty list of actions.

Before that, it was possible to create empty commits, which was very useful to surface some variables from the pipeline trigger in the commit message body.

Example

redhat/red-hat-ci-tools/kernel/cki-internal-pipelines/cki-trusted-contributors@4e1d3536

ARTIFACT_JOB_ID_aarch64 = 11407226115
ARTIFACT_JOB_ID_ppc64le = 11407226066
ARTIFACT_JOB_ID_s390x = 11407226138
ARTIFACT_JOB_ID_x86_64 = 11407226054
ARTIFACT_JOB_NAME_aarch64 = publish aarch64
ARTIFACT_JOB_NAME_ppc64le = publish ppc64le
ARTIFACT_JOB_NAME_s390x = publish s390x
ARTIFACT_JOB_NAME_x86_64 = publish x86_64
ARTIFACT_PIPELINE_ID = 2047836978
ARTIFACT_URL_aarch64 = https://gitlab.com/api/v4/projects/18194050/jobs/11407226115/artifacts
ARTIFACT_URL_ppc64le = https://gitlab.com/api/v4/projects/18194050/jobs/11407226066/artifacts
ARTIFACT_URL_s390x = https://gitlab.com/api/v4/projects/18194050/jobs/11407226138/artifacts
ARTIFACT_URL_x86_64 = https://gitlab.com/api/v4/projects/18194050/jobs/11407226054/artifacts
CKI_DEPLOYMENT_ENVIRONMENT = staging
CKI_RETRIGGER_PIPELINE = true
PIPELINE_TYPE = trusted
REQUESTED_PIPELINE_TYPE = /^(trusted|centos-rhel)$/
architecture = x86_64
architectures = x86_64 aarch64 s390x ppc64le
branch = main
builder_image = quay.io/cki/builder-stream10
cki_pipeline_branch = 72e4bf9f-bbe7-4a3d-8dda-f6ca8496944e
commit_hash = 15fa1bb956a22462e11a8a0e5f045531caef4115
debug_architectures = 
git_url = https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-10.git
kcidb_tree_name = c10s
kpet_tree_name = c10s
mr_id = 1456
mr_labels = 
mr_pipeline_id = 2047836801
mr_project_id = 56169485
mr_project_path = redhat/centos-stream/src/kernel/centos-stream-10
mr_source_branch_hash = 325904b40b0a5c41f6ceb70877f45edec70bee73
mr_title = Draft: Enable building libcpupower bindings for Stream 10
mr_url = [REDACTED]
native_tools = true
original_pipeline = https://gitlab.com/redhat/red-hat-ci-tools/kernel/cki-internal-pipelines/cki-trusted-contributors/-/pipelines/2047836978
package_name = kernel
pipeline_definition_branch_override = refs/merge-requests/2482/merge
rpmbuild_with = up zfcpdump base
run_redhat_self_test = true
skip_beaker = true
skip_build = true
skip_createrepo = true
skip_merge = true
skip_publish = true
srpm_make_target = dist-srpm
subject = Retrigger: Merge: Draft: Enable building libcpupower bindings for Stream 10
tests_only = True
title = Retrigger: Merge: Draft: Enable building libcpupower bindings for Stream 10
trigger_job_name = c10s_merge_request

Is there any reason to reject empty commits? The commit mentions gitlab-org/security/gitlab!5392, so there's not much public context as far as I could tell.

I know https://docs.gitlab.com/api/commits/#create-a-commit-with-multiple-files-and-actions states that actions[] is a required field for almost 10 years, but is it possible to change the validation so the API responds with Bad Request only if the field is completely missing?

Thanks for all the hard work! 🤗

Reproducer:

curl --request POST "https://gitlab.com/api/v4/projects/$PROJECT_ID/repository/commits" \
  --header "Content-Type: application/json" \
  --header "PRIVATE-TOKEN: $COM_GITLAB_TOKEN_PERSONAL" \
  --data '{
    "branch": "main",
    "commit_message": "Testing commit",
    "actions": []
  }'

# {"message":"400 Bad request - actions is required"}
Edited by 🤖 GitLab Bot 🤖