From 2c5bab2f8267a3a8bef8e3d5fea3243fb4d716e9 Mon Sep 17 00:00:00 2001 From: Johan Haals Date: Fri, 1 Oct 2021 13:28:40 +0200 Subject: [PATCH] catalog: Consider processing results with errors as failing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Fredrik Adelöw Co-authored-by: Patrik Oldsberg Signed-off-by: Johan Haals --- .changeset/eight-rockets-chew.md | 7 +++++++ .../processing/DefaultCatalogProcessingOrchestrator.ts | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 .changeset/eight-rockets-chew.md diff --git a/.changeset/eight-rockets-chew.md b/.changeset/eight-rockets-chew.md new file mode 100644 index 0000000000..bb3a252484 --- /dev/null +++ b/.changeset/eight-rockets-chew.md @@ -0,0 +1,7 @@ +--- +'@backstage/plugin-catalog-backend': minor +--- + +Errors emitted from processors are now considered a failure during entity processing and will prevent entities from being updated. The impact of this change is that when errors are emitted while for example reading a location, then ingestion effectively stops there. If you emit a number of entities along with just one error, then the error will be persisted on the current entity but the emitted entities will _not_ be stored. This fixes [a bug](https://github.com/backstage/backstage/issues/6973) where entities would get marked as orphaned rather than put in an error state when the catalog failed to read a location. + +In previous versions of the catalog, an emitted error was treated as a less severe problem than an exception thrown by the processor. We are now ensuring that the behavior is consistent for these two cases. Even though both thrown and emitted errors are treated the same, emitted errors stay around as they allow you to highlight multiple errors related to an entity at once. An emitted error will also only prevent the writing of the processing result, while a thrown error will skip the rest of the processing steps. diff --git a/plugins/catalog-backend/src/next/processing/DefaultCatalogProcessingOrchestrator.ts b/plugins/catalog-backend/src/next/processing/DefaultCatalogProcessingOrchestrator.ts index 6261c0e2ff..ab5d6c262a 100644 --- a/plugins/catalog-backend/src/next/processing/DefaultCatalogProcessingOrchestrator.ts +++ b/plugins/catalog-backend/src/next/processing/DefaultCatalogProcessingOrchestrator.ts @@ -157,7 +157,7 @@ export class DefaultCatalogProcessingOrchestrator ...collectorResults, completedEntity: entity, state: { cache: cache.collect() }, - ok: true, + ok: collectorResults.errors.length === 0, }; } catch (error) { this.options.logger.warn(error.message);