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 <heikki.hellgren@op.fi>
This commit is contained in:
Hellgren Heikki
2025-11-14 16:34:41 +02:00
parent cd79f31c8c
commit 8101ec1a53
2 changed files with 10 additions and 8 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-catalog-backend': patch
---
Fixed default refresh service to go through the whole ancestry of the entity.
@@ -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 });
});
}
}