diff --git a/.changeset/cuddly-coats-try.md b/.changeset/cuddly-coats-try.md new file mode 100644 index 0000000000..3b8bb654b2 --- /dev/null +++ b/.changeset/cuddly-coats-try.md @@ -0,0 +1,7 @@ +--- +'@backstage/plugin-catalog-backend': patch +--- + +Improve processing error logging. + +Adds `location` and `owner` to the logging meta if they are available. diff --git a/plugins/catalog-backend/src/processing/DefaultCatalogProcessingEngine.ts b/plugins/catalog-backend/src/processing/DefaultCatalogProcessingEngine.ts index 2cc0e2dc40..bef2878099 100644 --- a/plugins/catalog-backend/src/processing/DefaultCatalogProcessingEngine.ts +++ b/plugins/catalog-backend/src/processing/DefaultCatalogProcessingEngine.ts @@ -14,7 +14,11 @@ * limitations under the License. */ -import { Entity, stringifyEntityRef } from '@backstage/catalog-model'; +import { + ANNOTATION_LOCATION, + Entity, + stringifyEntityRef, +} from '@backstage/catalog-model'; import { assertError, serializeError, stringifyError } from '@backstage/errors'; import { Hash } from 'crypto'; import stableStringify from 'fast-json-stable-stringify'; @@ -116,11 +120,12 @@ export class DefaultCatalogProcessingEngine implements CatalogProcessingEngine { }); } + const location = + unprocessedEntity?.metadata?.annotations?.[ANNOTATION_LOCATION]; for (const error of result.errors) { - // TODO(freben): Try to extract the location out of the unprocessed - // entity and add as meta to the log lines this.logger.warn(error.message, { entity: entityRef, + location, }); } const errorsString = JSON.stringify(