From 8101ec1a53ad58e2632f5041c61b52cfe0622076 Mon Sep 17 00:00:00 2001 From: Hellgren Heikki Date: Fri, 14 Nov 2025 16:34:41 +0200 Subject: [PATCH] fix(catalog): fix refresh service ancestry to follow the tree if location is referenced by another location, that will not get updated properly Signed-off-by: Hellgren Heikki --- .changeset/tiny-suns-trade.md | 5 +++++ .../src/service/DefaultRefreshService.ts | 13 +++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) create mode 100644 .changeset/tiny-suns-trade.md diff --git a/.changeset/tiny-suns-trade.md b/.changeset/tiny-suns-trade.md new file mode 100644 index 0000000000..365e91ad69 --- /dev/null +++ b/.changeset/tiny-suns-trade.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog-backend': patch +--- + +Fixed default refresh service to go through the whole ancestry of the entity. diff --git a/plugins/catalog-backend/src/service/DefaultRefreshService.ts b/plugins/catalog-backend/src/service/DefaultRefreshService.ts index 99b78f900b..45a8f27c6e 100644 --- a/plugins/catalog-backend/src/service/DefaultRefreshService.ts +++ b/plugins/catalog-backend/src/service/DefaultRefreshService.ts @@ -29,20 +29,17 @@ export class DefaultRefreshService implements RefreshService { const { entityRefs } = await this.database.listAncestors(tx, { entityRef: options.entityRef, }); - const locationAncestor = entityRefs.find(ref => + + const locationAncestors = entityRefs.filter(ref => ref.startsWith('location:'), ); // TODO: Refreshes are currently scheduled(as soon as possible) for execution and will therefore happen in the future. // There's room for improvements here where the refresh could potentially hang or return an ID so that the user can check progress. - if (locationAncestor) { - await this.database.refresh(tx, { - entityRef: locationAncestor, - }); + for (const locationAncestor of locationAncestors) { + await this.database.refresh(tx, { entityRef: locationAncestor }); } - await this.database.refresh(tx, { - entityRef: options.entityRef, - }); + await this.database.refresh(tx, { entityRef: options.entityRef }); }); } }