From 8206f49ab1e3f4788bb3bfedb5421f591fd8e44c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Thu, 26 Sep 2024 15:35:44 +0200 Subject: [PATCH] make sure that etags don't expire spuriously MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fredrik Adelöw --- .changeset/weak-bottles-cross.md | 5 +++++ .../src/processors/UrlReaderProcessor.test.ts | 2 +- plugins/catalog-backend/src/processors/UrlReaderProcessor.ts | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 .changeset/weak-bottles-cross.md diff --git a/.changeset/weak-bottles-cross.md b/.changeset/weak-bottles-cross.md new file mode 100644 index 0000000000..c12d32d7db --- /dev/null +++ b/.changeset/weak-bottles-cross.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog-backend': patch +--- + +Fix a bug where etags were expiring too soon in the URL reader diff --git a/plugins/catalog-backend/src/processors/UrlReaderProcessor.test.ts b/plugins/catalog-backend/src/processors/UrlReaderProcessor.test.ts index 7e895c5344..545888e7cb 100644 --- a/plugins/catalog-backend/src/processors/UrlReaderProcessor.test.ts +++ b/plugins/catalog-backend/src/processors/UrlReaderProcessor.test.ts @@ -149,7 +149,7 @@ describe('UrlReaderProcessor', () => { expect(mockCache.get).toHaveBeenCalledWith('v1'); expect(mockCache.get).toHaveBeenCalledTimes(1); - expect(mockCache.set).toHaveBeenCalledTimes(0); + expect(mockCache.set).toHaveBeenCalledTimes(1); }); it('should fail load from url with error', async () => { diff --git a/plugins/catalog-backend/src/processors/UrlReaderProcessor.ts b/plugins/catalog-backend/src/processors/UrlReaderProcessor.ts index 9d76f5679f..e817e19616 100644 --- a/plugins/catalog-backend/src/processors/UrlReaderProcessor.ts +++ b/plugins/catalog-backend/src/processors/UrlReaderProcessor.ts @@ -111,6 +111,7 @@ export class UrlReaderProcessor implements CatalogProcessor { emit(parseResult); } emit(processingResult.refresh(`${location.type}:${location.target}`)); + await cache.set(CACHE_KEY, cacheItem); } else if (error.name === 'NotFoundError') { if (!optional) { emit(processingResult.notFoundError(location, message));