Skip to content

Backstage scaffolder: “Unable to create repository, 409 Conflict”

Kubernetestested on Backstage 1.55.0 (create-app 0.9.2), Forgejo

In practice templates usually fail on input. If someone enters a name that already exists as a repository, the Git platform rejects the creation with 409 Conflict. The publish step turns red and all following steps are skipped.

Symptom

Error: Unable to create repository, 409 Conflict, {"message":"The repository with th
Run completed with status: failed

In the GUI: a red bar, the step creating the repo in Forgejo with an exclamation mark, catalog registration skipped.

Diagnosis

Without the GUI you get the message from the last task's events.

ID=$(bs 'scaffolder/v2/tasks?limit=1' | jq -r '.tasks[0].id')
bs "scaffolder/v2/tasks/$ID/events" | jq -r '.[]
  | select(.type=="completion" or (.body.message | test("^Error")))
  | .body.message[0:84]'

Causes

publish:giteaThe repository already exists

The template creates a repository with the entered name. If it already exists, the Forgejo API answers 409 Conflict and the publish:gitea step aborts.

nichts kaputtLater steps are skipped

fetch:template only works in the temporary workspace, publish:gitea aborts before pushing, and the scaffolder skips all later steps (such as catalog:register).

Fix

START OVER opens the wizard with all previous inputs. Change name and repository, Review, Create – all steps turn green and the task is completed.

Don't: Deleting the existing repository so the template goes through. It probably belongs to another team.

▶
Break it yourself and find it – free
Backstage hands-on, day 5: software templates with fetch:template, publish:gitea and catalog:register, including the failure case.
Go to day 5 →

FAQ

Is anything left half-created after the error?

No. publish:gitea aborts while creating, before pushing; later steps do not run at all.

How do I prevent the error in the form?

With custom field validations and the EntityNamePicker, so taken names show up before the task runs.

Related error patterns

More