Backstage 1.50.0 codemod: Adds the required entityRef field to Location object literals from @backstage/catalog-client.
Background
In Backstage 1.50.0, the Location type in @backstage/catalog-client now includes a required entityRef: string field. Any code constructing or mocking Location objects (tests, fixtures, mock implementations) must include this field.
Production code consuming Location from API responses is unaffected -- the backend already populates entityRef.
What it does
Detects Location object literals with explicit type annotations (: Location, satisfies Location, as Location)
// After
const loc: Location = {
id: 'abc123',
type: 'url',
target: 'https://example.com/catalog-info.yaml',
entityRef: 'location:default/example', // TODO(backstage-codemod): replace with actual entityRef
}
Notes
The real entityRef format is location:default/generated-<sha1hex>. The codemod uses a placeholder since the actual value cannot be computed statically.
After running the codemod, search for TODO(backstage-codemod) to find all locations that need manual attention.
The optional AI fixup step (--param aiFixup=true) can handle edge cases like inferred types, dynamic mock setups, and test assertion objects.
Ready to evolve your codebase?
Build tailored, compiler-aware skills to assess, plan, and automate complex codebase changes.