diff --git a/packages/catalog-client/src/CatalogClient.ts b/packages/catalog-client/src/CatalogClient.ts index 3a4c0455ad..b2420bc71b 100644 --- a/packages/catalog-client/src/CatalogClient.ts +++ b/packages/catalog-client/src/CatalogClient.ts @@ -20,6 +20,7 @@ import { Location, LOCATION_ANNOTATION, ORIGIN_LOCATION_ANNOTATION, + parseEntityRef, stringifyEntityRef, stringifyLocationReference, } from '@backstage/catalog-model'; @@ -50,13 +51,7 @@ export class CatalogClient implements CatalogApi { request: CatalogEntityAncestorsRequest, options?: CatalogRequestOptions, ): Promise { - const { kind, namespace, name } = Object.fromEntries( - Object.entries(request.entityRef).map(([k, v]) => [ - k, - encodeURIComponent(v), - ]), - ); - + const { kind, namespace, name } = parseEntityRef(request.entityRef); return await this.requestRequired( 'GET', `/entities/by-name/${kind}/${namespace}/${name}/ancestry`, diff --git a/packages/catalog-client/src/types/api.ts b/packages/catalog-client/src/types/api.ts index 234c49c779..c7025e9452 100644 --- a/packages/catalog-client/src/types/api.ts +++ b/packages/catalog-client/src/types/api.ts @@ -30,7 +30,7 @@ export type CatalogEntitiesRequest = { /** @public */ export type CatalogEntityAncestorsRequest = { - entityRef: EntityName; + entityRef: string; }; /** @public */ diff --git a/plugins/catalog/src/components/EntityProcessingErrorsPanel/EntityProcessingErrorsPanel.tsx b/plugins/catalog/src/components/EntityProcessingErrorsPanel/EntityProcessingErrorsPanel.tsx index 65e594fb3b..0efc9d5b03 100644 --- a/plugins/catalog/src/components/EntityProcessingErrorsPanel/EntityProcessingErrorsPanel.tsx +++ b/plugins/catalog/src/components/EntityProcessingErrorsPanel/EntityProcessingErrorsPanel.tsx @@ -16,8 +16,6 @@ import { Entity, - EntityName, - getEntityName, stringifyEntityRef, UNSTABLE_EntityStatusItem, compareEntityToRef, @@ -51,7 +49,7 @@ type GetOwnAndAncestorsErrorsResponse = { }; async function getOwnAndAncestorsErrors( - entityRef: EntityName, + entityRef: string, catalogApi: CatalogApi, ): Promise { const ancestors = await catalogApi.getEntityAncestors({ entityRef }); @@ -78,7 +76,7 @@ export const hasCatalogProcessingErrors = async ( } const errors = await getOwnAndAncestorsErrors( - getEntityName(entity), + stringifyEntityRef(entity), catalogApi, ); return errors.items.length > 0; @@ -89,11 +87,11 @@ export const hasCatalogProcessingErrors = async ( */ export const EntityProcessingErrorsPanel = () => { const { entity } = useEntity(); + const entityRef = stringifyEntityRef(entity); const catalogApi = useApi(catalogApiRef); - const { loading, error, value } = useAsync(async () => { - return getOwnAndAncestorsErrors(getEntityName(entity), catalogApi); - }, [stringifyEntityRef(entity), catalogApi]); + return getOwnAndAncestorsErrors(entityRef, catalogApi); + }, [entityRef, catalogApi]); if (error) { return (