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