From fa6fa60445d681e3cc8a62f63a0bc1190398267e Mon Sep 17 00:00:00 2001 From: Jamie Tang Date: Wed, 9 Jul 2025 14:18:05 -0700 Subject: [PATCH 1/2] fix getLocationByEntity to use original_value Signed-off-by: Jamie Tang --- .changeset/shaggy-parrots-deny.md | 5 +++++ .../catalog-backend/src/providers/DefaultLocationStore.ts | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 .changeset/shaggy-parrots-deny.md diff --git a/.changeset/shaggy-parrots-deny.md b/.changeset/shaggy-parrots-deny.md new file mode 100644 index 0000000000..1c8d8bad7e --- /dev/null +++ b/.changeset/shaggy-parrots-deny.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog-backend': patch +--- + +Fixed getLocationByEntity to use `original_value` instead of `value` when querying search table diff --git a/plugins/catalog-backend/src/providers/DefaultLocationStore.ts b/plugins/catalog-backend/src/providers/DefaultLocationStore.ts index 2b3459ecb1..8420cbb8c4 100644 --- a/plugins/catalog-backend/src/providers/DefaultLocationStore.ts +++ b/plugins/catalog-backend/src/providers/DefaultLocationStore.ts @@ -137,15 +137,15 @@ export class DefaultLocationStore implements LocationStore, EntityProvider { entity_id: entityRow.entity_id, key: `metadata.annotations.${ANNOTATION_ORIGIN_LOCATION}`, }) - .select('value') + .select('original_value') .limit(1); - if (!searchRow?.value) { + if (!searchRow?.original_value) { throw new NotFoundError( `found no origin annotation for ref ${entityRefString}`, ); } - const { type, target } = parseLocationRef(searchRow.value); + const { type, target } = parseLocationRef(searchRow.original_value); const [locationRow] = await this.db('locations') .where({ type, target }) .select() From 4d63ed24235b8a4ac4126d38e185465ba2af4943 Mon Sep 17 00:00:00 2001 From: Jamie Tang Date: Wed, 9 Jul 2025 15:11:57 -0700 Subject: [PATCH 2/2] update DefaultLocationStore.test.ts Signed-off-by: Jamie Tang --- .../catalog-backend/src/providers/DefaultLocationStore.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/catalog-backend/src/providers/DefaultLocationStore.test.ts b/plugins/catalog-backend/src/providers/DefaultLocationStore.test.ts index 5e3f3e0b17..05e078723d 100644 --- a/plugins/catalog-backend/src/providers/DefaultLocationStore.test.ts +++ b/plugins/catalog-backend/src/providers/DefaultLocationStore.test.ts @@ -211,6 +211,7 @@ describe('DefaultLocationStore', () => { entity_id: entityId, key: `metadata.annotations.${ANNOTATION_ORIGIN_LOCATION}`, value: `url:https://example.com`, + original_value: `url:https://example.com`, }); await knex('locations').insert({