Skip to content

gitlab:repo:push fails with 400 when there are no commit actions needed (empty workspace / no changes) #34098

@Alabate

Description

@Alabate

📜 Issue Labels

  • Please familiarize yourself with the issue labels used in this project: LABELS.md

🔎 Search Terms

"gitlab:repo:push", "allow_empty", "Provide at least one action", "GitbeakerRequestError"

🗃️ Project Area

Software Templates

🔗 External Integration

GitLab

📝 Description & Context

The gitlab:repo:push scaffolder action calls GitLab’s commit API with an empty list of file actions when there is nothing to push. That happens in situations such as:

  • The workspace (or sourcePath) has no files to serialize, or
  • commitAction: auto and every file is treated as unchanged compared to the target branch (all actions end up as skip, so nothing is left to commit).

GitLab rejects an empty commit payload with HTTP 400 and a clear API message, for example:

Provide at least one action, or set allow_empty to true

Backstage then surfaces an InputError whose text suggests checking that remote files exist or that commitAction is correct, which does not match the real cause (no actions to send).

Example log excerpt:

2026-04-29T08:28:20.000Z Beginning step Push to GitLab
2026-04-29T08:28:21.000Z InputError: Committing the changes to scaffolder-gitlab-push-demo failed. Please verify that all files you're trying to modify exist in the repository. GitbeakerRequestError: 400 Bad request - Provide at least one action, or set allow_empty to true - 400 Bad request - Provide at least one action, or set allow_empty to true
    at Object.handler (/home/alabate/dev/tmp/backstage/plugins/scaffolder-backend-module-gitlab/src/actions/gitlabRepoPush.ts:230:17)
    at process.processTicksAndRejections (node:internal/process/task_queues:104:5)
    at async NunjucksWorkflowRunner.executeStep (/home/alabate/dev/tmp/backstage/plugins/scaffolder-backend/src/scaffolder/tasks/NunjucksWorkflowRunner.ts:534:9)
    at async NunjucksWorkflowRunner.execute (/home/alabate/dev/tmp/backstage/plugins/scaffolder-backend/src/scaffolder/tasks/NunjucksWorkflowRunner.ts:729:11)
    at async TaskWorker.runOneTask (/home/alabate/dev/tmp/backstage/plugins/scaffolder-backend/src/scaffolder/tasks/TaskWorker.ts:224:26)
    at async run (/home/alabate/dev/tmp/backstage/node_modules/p-queue/dist/index.js:163:29)

Relevant code:

👍 Expected Behavior

There is two reasonable ways to handle "nothing to commit":

  • Call the commit API with allow_empty: true so GitLab records an explicit empty commit on the branch.
  • Do not call the commit API when the computed actions list is empty: treat the step as a successful no-op (optionally log a warning), and expose outputs that reflect that no new commit was created (e.g. empty commitHash).

I think the "no commit" option with a warning log would be the best solution. In most real situations, creating an empty commit adds noise to history without carrying useful work. The usual intent of this scaffolder action is “ensure branch/repo state matches the workspace,” which is already satisfied when there is nothing to push.

📦 Reproduction Repo

1551a1a

🥾 Reproduction steps

  • The commit above contains a template that should help you reproduce the issue
  • When you first start the scaffolder template, it will create a commit with a new test-file.txt without issues
  • If you start it again without changing the content of the file, it will crash with the error above because nothing needs to be pushed.

Have you read the Code of Conduct?

Are you willing to submit PR?

Yes, and I have enough information to get started

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions