From e6182115ab56fe7047764bbf409b3920a258cdcf Mon Sep 17 00:00:00 2001 From: gioboa Date: Tue, 3 Jun 2025 14:52:02 +0200 Subject: [PATCH 1/2] chore: throw error with duplicate action key --- js/core/src/registry.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/js/core/src/registry.ts b/js/core/src/registry.ts index fdc95f5891..477c168dbe 100644 --- a/js/core/src/registry.ts +++ b/js/core/src/registry.ts @@ -200,9 +200,8 @@ export class Registry { const key = `/${type}/${action.__action.name}`; logger.debug(`registering ${key}`); if (this.actionsById.hasOwnProperty(key)) { - // TODO: Make this an error! - logger.warn( - `WARNING: ${key} already has an entry in the registry. Overwriting.` + logger.error( + `Failed to register ${key} action because it's already in the registry.` ); } this.actionsById[key] = action; @@ -219,9 +218,8 @@ export class Registry { const key = `/${type}/${name}`; logger.debug(`registering ${key} (async)`); if (this.actionsById.hasOwnProperty(key)) { - // TODO: Make this an error! - logger.warn( - `WARNING: ${key} already has an entry in the registry. Overwriting.` + logger.error( + `Failed to register ${key} action because it's already in the registry.` ); } this.actionsById[key] = action; From a2ad63667dc512840d0ca8f8b7889d3d252bb24b Mon Sep 17 00:00:00 2001 From: gioboa Date: Mon, 7 Jul 2025 08:41:17 +0200 Subject: [PATCH 2/2] chore: throw error with duplicate action key --- js/core/src/registry.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/js/core/src/registry.ts b/js/core/src/registry.ts index 477c168dbe..a15ee6e95c 100644 --- a/js/core/src/registry.ts +++ b/js/core/src/registry.ts @@ -200,9 +200,10 @@ export class Registry { const key = `/${type}/${action.__action.name}`; logger.debug(`registering ${key}`); if (this.actionsById.hasOwnProperty(key)) { - logger.error( - `Failed to register ${key} action because it's already in the registry.` - ); + throw new GenkitError({ + status: 'INVALID_ARGUMENT', + message: `Failed to register ${key} action because it's already in the registry.`, + }); } this.actionsById[key] = action; } @@ -218,9 +219,10 @@ export class Registry { const key = `/${type}/${name}`; logger.debug(`registering ${key} (async)`); if (this.actionsById.hasOwnProperty(key)) { - logger.error( - `Failed to register ${key} action because it's already in the registry.` - ); + throw new GenkitError({ + status: 'INVALID_ARGUMENT', + message: `Failed to register ${key} action because it's already in the registry.`, + }); } this.actionsById[key] = action; }