From 37b4eaf462467df0fa7ee896b7bf7c3402486bcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustaf=20R=C3=A4ntil=C3=A4?= Date: Thu, 28 Aug 2025 15:25:30 +0200 Subject: [PATCH] Make the action 'get-catalog-entity' throw ConflictError instead of Error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Gustaf Räntilä --- .changeset/curvy-sites-rhyme.md | 5 +++++ .../src/actions/createGetCatalogEntityAction.ts | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .changeset/curvy-sites-rhyme.md diff --git a/.changeset/curvy-sites-rhyme.md b/.changeset/curvy-sites-rhyme.md new file mode 100644 index 0000000000..1de9a21e77 --- /dev/null +++ b/.changeset/curvy-sites-rhyme.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog-backend': patch +--- + +The 'get-catalog-entity' action now throws a ConflictError instead of generic Error if multiple entities are found, so MCP call doesn't fail with 500. diff --git a/plugins/catalog-backend/src/actions/createGetCatalogEntityAction.ts b/plugins/catalog-backend/src/actions/createGetCatalogEntityAction.ts index da33064c08..a1c7cefe78 100644 --- a/plugins/catalog-backend/src/actions/createGetCatalogEntityAction.ts +++ b/plugins/catalog-backend/src/actions/createGetCatalogEntityAction.ts @@ -15,7 +15,7 @@ */ import { ActionsRegistryService } from '@backstage/backend-plugin-api/alpha'; import { stringifyEntityRef } from '@backstage/catalog-model'; -import { InputError } from '@backstage/errors'; +import { ConflictError, InputError } from '@backstage/errors'; import { CatalogService } from '@backstage/plugin-catalog-node'; export const createGetCatalogEntityAction = ({ @@ -76,7 +76,7 @@ Each entity is identified by a unique entity reference, which is a string of the } if (items.length > 1) { - throw new Error( + throw new ConflictError( `Multiple entities found with name "${ input.name }", please provide more specific filters. Entities found: ${items