diff --git a/plugins/catalog-backend/src/ingestion/processors/UrlReaderProcessor.ts b/plugins/catalog-backend/src/ingestion/processors/UrlReaderProcessor.ts index 67bd0715df..a555c54ecd 100644 --- a/plugins/catalog-backend/src/ingestion/processors/UrlReaderProcessor.ts +++ b/plugins/catalog-backend/src/ingestion/processors/UrlReaderProcessor.ts @@ -62,13 +62,13 @@ export class UrlReaderProcessor implements CatalogProcessor { const cacheItem = await cache.get(CACHE_KEY); try { - const [output, newEtag] = await this.doRead( + const { response, etag: newEtag } = await this.doRead( location.target, cacheItem?.etag, ); const parseResults: CatalogProcessorResult[] = []; - for (const item of output) { + for (const item of response) { for await (const parseResult of parser({ data: item.data, location: { type: location.type, target: item.url }, @@ -91,7 +91,7 @@ export class UrlReaderProcessor implements CatalogProcessor { for (const parseResult of cacheItem.value) { emit(parseResult); } - cache.set(CACHE_KEY, cacheItem); + await cache.set(CACHE_KEY, cacheItem); } else if (error.name === 'NotFoundError') { if (!optional) { emit(result.notFoundError(location, message)); @@ -107,7 +107,7 @@ export class UrlReaderProcessor implements CatalogProcessor { private async doRead( location: string, etag?: string, - ): Promise<[response: { data: Buffer; url: string }[], etag?: string]> { + ): Promise<{ response: { data: Buffer; url: string }[]; etag?: string }> { // Does it contain globs? I.e. does it contain asterisks or question marks // (no curly braces for now) const { filepath } = parseGitUrl(location); @@ -118,16 +118,19 @@ export class UrlReaderProcessor implements CatalogProcessor { url: file.url, data: await limiter(file.content), })); - return [await Promise.all(output), response.etag]; + return { response: await Promise.all(output), etag: response.etag }; } // Otherwise do a plain read, prioritizing readUrl if available if (this.options.reader.readUrl) { const data = await this.options.reader.readUrl(location, { etag }); - return [[{ url: location, data: await data.buffer() }], data.etag]; + return { + response: [{ url: location, data: await data.buffer() }], + etag: data.etag, + }; } const data = await this.options.reader.read(location); - return [[{ url: location, data }]]; + return { response: [{ url: location, data }] }; } } diff --git a/plugins/catalog-backend/src/ingestion/processors/types.ts b/plugins/catalog-backend/src/ingestion/processors/types.ts index 752789703f..7c201ca319 100644 --- a/plugins/catalog-backend/src/ingestion/processors/types.ts +++ b/plugins/catalog-backend/src/ingestion/processors/types.ts @@ -24,7 +24,7 @@ import { JsonValue } from '@backstage/config'; export type CatalogProcessor = { /** * A unique identifier for the Catalog Processor. - * It's strongly recommended implement getProcessorName as this method will be required in the future. + * It's strongly recommended to implement getProcessorName as this method will be required in the future. */ getProcessorName?(): string;