backend-app-api: throw error if trying to override metadata service
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/backend-app-api': patch
|
||||
---
|
||||
|
||||
An error will now be thrown if attempting to override the plugin metadata service.
|
||||
@@ -19,6 +19,7 @@ import {
|
||||
BackendFeature,
|
||||
ExtensionPoint,
|
||||
ServiceRef,
|
||||
coreServices,
|
||||
} from '@backstage/backend-plugin-api';
|
||||
import { BackstageBackend } from './BackstageBackend';
|
||||
|
||||
@@ -80,6 +81,11 @@ export function createSpecializedBackend(
|
||||
const ids = Array.from(duplicates).join(', ');
|
||||
throw new Error(`Duplicate service implementations provided for ${ids}`);
|
||||
}
|
||||
if (exists.has(coreServices.pluginMetadata.id)) {
|
||||
throw new Error(
|
||||
`The ${coreServices.pluginMetadata.id} service cannot be overridden`,
|
||||
);
|
||||
}
|
||||
|
||||
return new BackstageBackend(services);
|
||||
}
|
||||
|
||||
@@ -55,4 +55,18 @@ describe('createBackend', () => {
|
||||
'Duplicate service implementations provided for core.rootLifecycle',
|
||||
);
|
||||
});
|
||||
|
||||
it('should throw when providing a plugin metadata service implementation', () => {
|
||||
expect(() =>
|
||||
createBackend({
|
||||
services: [
|
||||
createServiceFactory({
|
||||
service: coreServices.pluginMetadata,
|
||||
deps: {},
|
||||
factory: async () => async () => ({ getId: () => 'test' }),
|
||||
}),
|
||||
],
|
||||
}),
|
||||
).toThrow('The core.plugin-metadata service cannot be overridden');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user