diff --git a/lib/modules/datasource/rubygems/metadata-cache.spec.ts b/lib/modules/datasource/rubygems/metadata-cache.spec.ts index c1bc38244755dc487af115a5959938f9c0713941..ab7960f20306ea9cb884649b3d0ad8673984939c 100644 --- a/lib/modules/datasource/rubygems/metadata-cache.spec.ts +++ b/lib/modules/datasource/rubygems/metadata-cache.spec.ts @@ -192,7 +192,7 @@ describe('modules/datasource/rubygems/metadata-cache', () => { }); }); - it('throws on unknown error', async () => { + it('returns fallback result on unknown error', async () => { const cache = new MetadataCache(new Http('test')); httpMock @@ -201,9 +201,14 @@ describe('modules/datasource/rubygems/metadata-cache', () => { .reply(500); const versions = ['1', '2', '3']; + const res = await cache.getRelease( + 'https://rubygems.org', + 'foobar', + versions + ); - await expect( - cache.getRelease('https://rubygems.org', 'foobar', versions) - ).rejects.toThrow(); + expect(res).toEqual({ + releases: [{ version: '1' }, { version: '2' }, { version: '3' }], + }); }); }); diff --git a/lib/modules/datasource/rubygems/metadata-cache.ts b/lib/modules/datasource/rubygems/metadata-cache.ts index a5f1de6893ce96174591d0bbf5e9a0421566ea24..3084ae6587cefe2cde09c742bd2fdb04724631d0 100644 --- a/lib/modules/datasource/rubygems/metadata-cache.ts +++ b/lib/modules/datasource/rubygems/metadata-cache.ts @@ -1,6 +1,7 @@ import hasha from 'hasha'; +import { logger } from '../../../logger'; import * as packageCache from '../../../util/cache/package'; -import { Http, HttpError } from '../../../util/http'; +import type { Http } from '../../../util/http'; import { joinUrlParts } from '../../../util/url'; import type { ReleaseResult } from '../types'; import { GemMetadata, GemVersions } from './schema'; @@ -62,12 +63,9 @@ export class MetadataCache { ); return data; } catch (err) { - if (err instanceof HttpError && err.response?.statusCode === 404) { - const releases = versions.map((version) => ({ version })); - return { releases }; - } - - throw err; + logger.debug({ err }, 'Rubygems: failed to fetch metadata'); + const releases = versions.map((version) => ({ version })); + return { releases }; } } }