Revert locationKey change; keep allowedLocationTypes validation on updateLocation

Reverts the location_entity_ref-as-locationKey change: the full mutation on
startup would compare existing rows (locationKey = url:target) against the
new values and trigger a remove+add cycle for every location. The type:target
locationKey is kept as-is to preserve the existing startup contract.

Keeps the allowedLocationTypes validation added to DefaultLocationService.updateLocation.

Signed-off-by: Fredrik Adelöw <freben@spotify.com>
Made-with: Cursor
This commit is contained in:
Fredrik Adelöw
2026-04-10 13:57:47 +02:00
parent 068f4739ac
commit 907bd33833
2 changed files with 21 additions and 32 deletions
@@ -154,10 +154,8 @@ describe('DefaultLocationStore', () => {
type: 'url',
},
}),
locationKey: computeLocationEntityRef(
'url',
'https://github.com/backstage/demo/blob/master/catalog-info.yml',
),
locationKey:
'url:https://github.com/backstage/demo/blob/master/catalog-info.yml',
},
]),
});
@@ -265,10 +263,8 @@ describe('DefaultLocationStore', () => {
type: 'url',
},
}),
locationKey: computeLocationEntityRef(
'url',
'https://github.com/backstage/demo/blob/master/catalog-info.yml',
),
locationKey:
'url:https://github.com/backstage/demo/blob/master/catalog-info.yml',
},
],
});
@@ -345,9 +341,7 @@ describe('DefaultLocationStore', () => {
entity: expect.objectContaining({
spec: { type: 'url', target: 'https://example.com/new' },
}),
// locationKey is the stable entityRef from when the location was
// originally created, not derived from the new type:target
locationKey: created.entityRef,
locationKey: 'url:https://example.com/new',
},
],
});
@@ -473,7 +467,7 @@ describe('DefaultLocationStore', () => {
type: 'url',
},
}),
locationKey: computeLocationEntityRef('url', matchTarget),
locationKey: `url:${matchTarget}`,
},
],
removed: [],
@@ -488,7 +482,7 @@ describe('DefaultLocationStore', () => {
type: 'url',
},
}),
locationKey: computeLocationEntityRef('url', otherTarget),
locationKey: `url:${otherTarget}`,
},
],
removed: [],
@@ -590,7 +584,7 @@ describe('DefaultLocationStore', () => {
type: 'url',
},
}),
locationKey: computeLocationEntityRef('url', matchTarget),
locationKey: `url:${matchTarget}`,
},
],
removed: [],
@@ -605,7 +599,7 @@ describe('DefaultLocationStore', () => {
type: 'url',
},
}),
locationKey: computeLocationEntityRef('url', otherTarget),
locationKey: `url:${otherTarget}`,
},
],
removed: [],
@@ -657,10 +651,7 @@ describe('DefaultLocationStore', () => {
type: 'url',
},
}),
locationKey: computeLocationEntityRef(
'url',
'https://github.com/backstage/freben/blob/master/catalog-info.yaml',
),
locationKey: `url:https://github.com/backstage/freben/blob/master/catalog-info.yaml`,
},
],
removed: [],
@@ -732,7 +723,7 @@ describe('DefaultLocationStore', () => {
type: 'url',
},
}),
locationKey: computeLocationEntityRef('url', matchTarget),
locationKey: `url:${matchTarget}`,
},
],
removed: [],
@@ -747,7 +738,7 @@ describe('DefaultLocationStore', () => {
type: 'url',
},
}),
locationKey: computeLocationEntityRef('url', otherTarget),
locationKey: `url:${otherTarget}`,
},
],
removed: [],
@@ -849,7 +840,7 @@ describe('DefaultLocationStore', () => {
type: 'url',
},
}),
locationKey: computeLocationEntityRef('url', matchTarget),
locationKey: `url:${matchTarget}`,
},
],
removed: [],
@@ -864,7 +855,7 @@ describe('DefaultLocationStore', () => {
type: 'url',
},
}),
locationKey: computeLocationEntityRef('url', otherTarget),
locationKey: `url:${otherTarget}`,
},
],
removed: [],
@@ -915,10 +906,7 @@ describe('DefaultLocationStore', () => {
type: 'url',
},
}),
locationKey: computeLocationEntityRef(
'url',
'https://github.com/freben/demo-renamed/blob/master/folder/catalog-info.yaml',
),
locationKey: `url:https://github.com/freben/demo-renamed/blob/master/folder/catalog-info.yaml`,
},
],
removed: [],
@@ -23,6 +23,7 @@ import {
DbRefreshStateRow,
DbSearchRow,
} from '../database/tables';
import { getEntityLocationRef } from '../processing/util';
import {
EntityProvider,
EntityProviderConnection,
@@ -116,7 +117,7 @@ export class DefaultLocationStore implements LocationStore, EntityProvider {
});
await this.connection.applyMutation({
type: 'delta',
added: [{ entity, locationKey: location.location_entity_ref }],
added: [{ entity, locationKey: getEntityLocationRef(entity) }],
removed: [],
});
@@ -266,7 +267,7 @@ export class DefaultLocationStore implements LocationStore, EntityProvider {
await this.connection.applyMutation({
type: 'delta',
added: [{ entity, locationKey: row.location_entity_ref }],
added: [{ entity, locationKey: getEntityLocationRef(entity) }],
removed: [],
});
@@ -302,7 +303,7 @@ export class DefaultLocationStore implements LocationStore, EntityProvider {
await this.connection.applyMutation({
type: 'delta',
added: [],
removed: [{ entity, locationKey: deleted.location_entity_ref }],
removed: [{ entity, locationKey: getEntityLocationRef(entity) }],
});
}
@@ -368,7 +369,7 @@ export class DefaultLocationStore implements LocationStore, EntityProvider {
location,
locationEntityRef: location.location_entity_ref,
});
return { entity, locationKey: location.location_entity_ref };
return { entity, locationKey: getEntityLocationRef(entity) };
});
await this.connection.applyMutation({
@@ -499,7 +500,7 @@ export class DefaultLocationStore implements LocationStore, EntityProvider {
location,
locationEntityRef: location.location_entity_ref,
});
return { entity, locationKey: location.location_entity_ref };
return { entity, locationKey: getEntityLocationRef(entity) };
}),
removed: [],
});