Make the action 'get-catalog-entity' throw ConflictError instead of Error

Signed-off-by: Gustaf Räntilä <g.rantila@gmail.com>
This commit is contained in:
Gustaf Räntilä
2025-08-28 15:25:30 +02:00
parent d08b0c9630
commit 37b4eaf462
2 changed files with 7 additions and 2 deletions
+5
View File
@@ -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.
@@ -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