diff --git a/.changeset/gorgeous-bobcats-press.md b/.changeset/gorgeous-bobcats-press.md new file mode 100644 index 0000000000..6193918cb7 --- /dev/null +++ b/.changeset/gorgeous-bobcats-press.md @@ -0,0 +1,5 @@ +--- +'@backstage/backend-app-api': patch +--- + +Include the extension point ID and the module ID in the backend init error message. diff --git a/packages/backend-app-api/src/wiring/BackendInitializer.test.ts b/packages/backend-app-api/src/wiring/BackendInitializer.test.ts index b5b53083a9..c025d19fa7 100644 --- a/packages/backend-app-api/src/wiring/BackendInitializer.test.ts +++ b/packages/backend-app-api/src/wiring/BackendInitializer.test.ts @@ -321,7 +321,7 @@ describe('BackendInitializer', () => { })(), ); await expect(init.start()).rejects.toThrow( - "Extension point registered for plugin 'test-a' may not be used by module for plugin 'test-b'", + "Illegal dependency: Module 'mod' for plugin 'test-b' attempted to depend on extension point 'a' for plugin 'test-a'. Extension points can only be used within their plugin's scope.", ); }); }); diff --git a/packages/backend-app-api/src/wiring/BackendInitializer.ts b/packages/backend-app-api/src/wiring/BackendInitializer.ts index 4969f82176..2da3a5a226 100644 --- a/packages/backend-app-api/src/wiring/BackendInitializer.ts +++ b/packages/backend-app-api/src/wiring/BackendInitializer.ts @@ -55,6 +55,7 @@ export class BackendInitializer { async #getInitDeps( deps: { [name: string]: ServiceOrExtensionPoint }, pluginId: string, + moduleId?: string, ) { const result = new Map(); const missingRefs = new Set(); @@ -64,7 +65,7 @@ export class BackendInitializer { if (ep) { if (ep.pluginId !== pluginId) { throw new Error( - `Extension point registered for plugin '${ep.pluginId}' may not be used by module for plugin '${pluginId}'`, + `Illegal dependency: Module '${moduleId}' for plugin '${pluginId}' attempted to depend on extension point '${ref.id}' for plugin '${ep.pluginId}'. Extension points can only be used within their plugin's scope.`, ); } result.set(name, ep.impl); @@ -260,6 +261,7 @@ export class BackendInitializer { const moduleDeps = await this.#getInitDeps( moduleInit.init.deps, pluginId, + moduleId, ); await moduleInit.init.func(moduleDeps).catch(error => { throw new ForwardedError( diff --git a/packages/backend-test-utils/src/next/wiring/TestBackend.test.ts b/packages/backend-test-utils/src/next/wiring/TestBackend.test.ts index d71c774dd9..968237f11d 100644 --- a/packages/backend-test-utils/src/next/wiring/TestBackend.test.ts +++ b/packages/backend-test-utils/src/next/wiring/TestBackend.test.ts @@ -307,7 +307,7 @@ describe('TestBackend', () => { ], }), ).rejects.toThrow( - "Extension point registered for plugin 'testA' may not be used by module for plugin 'testB'", + "Illegal dependency: Module 'test' for plugin 'testB' attempted to depend on extension point 'a' for plugin 'testA'. Extension points can only be used within their plugin's scope.", ); });