From e22790d97a60e6fe5ad70560556994af81b07b0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Thu, 24 Aug 2023 14:46:54 +0200 Subject: [PATCH] address comments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fredrik Adelöw --- .../frontend-app-api/src/wiring/parameters.test.ts | 13 ++++++------- packages/frontend-app-api/src/wiring/parameters.ts | 12 +++++++++--- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/packages/frontend-app-api/src/wiring/parameters.test.ts b/packages/frontend-app-api/src/wiring/parameters.test.ts index 9da03bb563..88ab61e769 100644 --- a/packages/frontend-app-api/src/wiring/parameters.test.ts +++ b/packages/frontend-app-api/src/wiring/parameters.test.ts @@ -347,13 +347,12 @@ describe('expandShorthandExtensionParameters', () => { }); }); - it('supports object id', () => { - expect( - run({ 'core.router/routes': { id: 'example-package#MyRouter' } }), - ).toEqual({ - id: 'example-package#MyRouter', - at: 'core.router/routes', - }); + it('supports object id only in the key', () => { + expect(() => + run({ 'core.router/routes': { id: 'some.id' } }), + ).toThrowErrorMatchingInlineSnapshot( + `"Invalid extension configuration at app.extensions[1][core.router/routes].id, must not specify 'id' when the extension input ID form of the key is used (with a slash); please replace the key 'core.router/routes' with the id instead, and put that key in the 'at' field"`, + ); expect(() => run({ 'core.router/routes': { diff --git a/packages/frontend-app-api/src/wiring/parameters.ts b/packages/frontend-app-api/src/wiring/parameters.ts index 4d934d8e99..72c01d551e 100644 --- a/packages/frontend-app-api/src/wiring/parameters.ts +++ b/packages/frontend-app-api/src/wiring/parameters.ts @@ -153,7 +153,6 @@ export function expandShorthandExtensionParameters( // The remaining case is the generic object. Example YAML: // - core.router/routes: - // id: redirects.catalog // extension: '@backstage/core-app-api#Redirect' // config: // path: / @@ -186,9 +185,16 @@ export function expandShorthandExtensionParameters( ), ); } - if (id === undefined) { - id = generateExtensionId(); + if (id !== undefined) { + throw new Error( + errorMsg( + `must not specify 'id' when the extension input ID form of the key is used (with a slash); please replace the key '${key}' with the id instead, and put that key in the 'at' field`, + key, + 'id', + ), + ); } + id = generateExtensionId(); at = key; } else { if (id !== undefined) {