diff --git a/plugins/catalog-backend/src/service/DefaultLocationService.test.ts b/plugins/catalog-backend/src/service/DefaultLocationService.test.ts index e2b82ad2c0..562bae4867 100644 --- a/plugins/catalog-backend/src/service/DefaultLocationService.test.ts +++ b/plugins/catalog-backend/src/service/DefaultLocationService.test.ts @@ -196,7 +196,7 @@ describe('DefaultLocationServiceTest', () => { { type: 'url', target: 'https://backstage.io/catalog-info.yaml' }, true, ), - ).rejects.toThrowError('Duplicate nested entity: foo'); + ).rejects.toThrowError('Duplicate nested entity: location:default/foo'); }); it('should return exists false when the location does not exist beforehand', async () => { diff --git a/plugins/catalog-backend/src/service/DefaultLocationService.ts b/plugins/catalog-backend/src/service/DefaultLocationService.ts index d28112eda3..8dd2274842 100644 --- a/plugins/catalog-backend/src/service/DefaultLocationService.ts +++ b/plugins/catalog-backend/src/service/DefaultLocationService.ts @@ -19,6 +19,7 @@ import { LocationSpec, LOCATION_ANNOTATION, ORIGIN_LOCATION_ANNOTATION, + stringifyEntityRef, } from '@backstage/catalog-model'; import { CatalogProcessingOrchestrator, @@ -69,13 +70,18 @@ export class DefaultLocationService implements LocationService { }); if (processed.ok) { - const { metadata, kind } = processed.completedEntity; if ( entities.some( - e => e.metadata.name === metadata.name && e.kind === kind, + e => + stringifyEntityRef(e) === + stringifyEntityRef(processed.completedEntity), ) ) { - throw new Error(`Duplicate nested entity: ${metadata.name}`); + throw new Error( + `Duplicate nested entity: ${stringifyEntityRef( + processed.completedEntity, + )}`, + ); } unprocessedEntities.push(...processed.deferredEntities); entities.push(processed.completedEntity);