Skip to content

Backstage: “metadata.name is not valid” – policy check failed

Kubernetestested on Backstage 1.55.0 (create-app 0.9.2)

When registering or analysing a catalog-info.yaml, Backstage checks the naming rules first. A space or another special character in metadata.name leads to Policy check failed – the entity never enters the catalog.

Symptom

InputError: Policy check failed for component:default/sendungs archiv; caused by
  Error: "metadata.name" is not valid; expected a string that is sequences of
  [a-zA-Z0-9] separated by any of [-_.], at most 63 characters …

The message names the broken name and the rule.

Diagnosis

The same dry run the GUI's ANALYZE runs checks a file without registering it.

pruefe() {
  local u="$FORGEJO/kranich/sendungsverfolgung/src/branch/main/$1"
  curl -s -H "Authorization: Bearer $BACKSTAGE_TOKEN" \
    -H 'Content-Type: application/json' -X POST \
    "$BACKSTAGE/api/catalog/locations?dryRun=true" \
    -d "{\"type\":\"url\",\"target\":\"$u\"}" \
    | jq -r '.error.message // "ok"' | cut -c1-170
}

Causes

LeerzeichenIllegal character in the name

metadata.name may only consist of letters and digits separated by -, _ or ., at most 63 characters. Uppercase letters are allowed; the space in “sendungs archiv” is not.

unbekannter KindRelated error: kind not allowed

An unknown kind already fails at catalog.rules before any schema is checked.

NotAllowedError: Entity komponente:default/sendungs-archiv at url:http://127.0.0…
  is not of an allowed kind for that location

Fix

Bring metadata.name into an allowed form (for example sendungs-archiv), push and check or register again.

Don't: Confusing the name with display text. For a readable label with spaces there is metadata.title.

▶
Break it yourself and find it – free
Backstage hands-on, day 2: the data model, required fields, naming rules and dry runs against the catalog API.
Go to day 2 →

FAQ

Are uppercase letters allowed?

Yes. Only spaces and characters other than -, _ and . are forbidden.

How do I check many files before merging?

With the dry run against /api/catalog/locations?dryRun=true, for example in CI.

Related error patterns

More