From cb090966073d3db5802abc2983f11db889afa9e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Fri, 25 Feb 2022 13:56:18 +0100 Subject: [PATCH] better 'missing annotation' error messages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fredrik Adelöw --- .changeset/tough-clocks-enjoy.md | 5 +++++ plugins/catalog-backend/src/processing/util.ts | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 .changeset/tough-clocks-enjoy.md diff --git a/.changeset/tough-clocks-enjoy.md b/.changeset/tough-clocks-enjoy.md new file mode 100644 index 0000000000..90e00382df --- /dev/null +++ b/.changeset/tough-clocks-enjoy.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog-backend': patch +--- + +Tweaked the wording of the "does not have a location" errors to include the actual missing annotation name, to help users better in fixing their inputs. diff --git a/plugins/catalog-backend/src/processing/util.ts b/plugins/catalog-backend/src/processing/util.ts index 5cf7821371..94634f794a 100644 --- a/plugins/catalog-backend/src/processing/util.ts +++ b/plugins/catalog-backend/src/processing/util.ts @@ -37,7 +37,9 @@ export function getEntityLocationRef(entity: Entity): string { const ref = entity.metadata.annotations?.[ANNOTATION_LOCATION]; if (!ref) { const entityRef = stringifyEntityRef(entity); - throw new InputError(`Entity '${entityRef}' does not have a location`); + throw new InputError( + `Entity '${entityRef}' does not have the annotation ${ANNOTATION_LOCATION}`, + ); } return ref; } @@ -47,7 +49,7 @@ export function getEntityOriginLocationRef(entity: Entity): string { if (!ref) { const entityRef = stringifyEntityRef(entity); throw new InputError( - `Entity '${entityRef}' does not have an origin location`, + `Entity '${entityRef}' does not have the annotation ${ANNOTATION_ORIGIN_LOCATION}`, ); } return ref;