From a3071707dc8a0be5cb018c1b15809bbeb2a20c3d Mon Sep 17 00:00:00 2001 From: Sergei Zharinov Date: Fri, 1 Nov 2024 18:26:12 -0300 Subject: [PATCH 1/2] fix(maven): Reject releases only for default registries --- lib/modules/datasource/maven/index.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/modules/datasource/maven/index.ts b/lib/modules/datasource/maven/index.ts index 3738414d501237..b1443a7d8a1da9 100644 --- a/lib/modules/datasource/maven/index.ts +++ b/lib/modules/datasource/maven/index.ts @@ -277,7 +277,10 @@ export class MavenDatasource extends Datasource { const res = await checkResource(this.http, artifactUrl); - if (res === 'not-found' || res === 'error') { + if ( + this.defaultRegistryUrls.includes(registryUrl) && + (res === 'not-found' || res === 'error') + ) { return 'reject'; } From b4760805f1d66537755dd28c126a1f133608df3c Mon Sep 17 00:00:00 2001 From: Sergei Zharinov Date: Sat, 2 Nov 2024 10:26:27 -0300 Subject: [PATCH 2/2] Fix tests and limit rejection only to maven central --- lib/modules/datasource/maven/index.spec.ts | 16 ++++++++-------- lib/modules/datasource/maven/index.ts | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/modules/datasource/maven/index.spec.ts b/lib/modules/datasource/maven/index.spec.ts index 265910390b2092..a00b63dc4aac71 100644 --- a/lib/modules/datasource/maven/index.spec.ts +++ b/lib/modules/datasource/maven/index.spec.ts @@ -790,7 +790,7 @@ describe('modules/datasource/maven/index', () => { }); }); - it('returns null for deleted object', async () => { + it('handles deleted object', async () => { s3mock .on(HeadObjectCommand, { Bucket: 'bucket', @@ -805,10 +805,10 @@ describe('modules/datasource/maven/index', () => { releaseOrig, ); - expect(res).toBeNull(); + expect(res).toBe(releaseOrig); }); - it('returns null for NotFound response', async () => { + it('handles NotFound response', async () => { s3mock .on(HeadObjectCommand, { Bucket: 'bucket', @@ -823,10 +823,10 @@ describe('modules/datasource/maven/index', () => { releaseOrig, ); - expect(res).toBeNull(); + expect(res).toBe(releaseOrig); }); - it('returns null for NoSuchKey response', async () => { + it('handles NoSuchKey response', async () => { s3mock .on(HeadObjectCommand, { Bucket: 'bucket', @@ -841,10 +841,10 @@ describe('modules/datasource/maven/index', () => { releaseOrig, ); - expect(res).toBeNull(); + expect(res).toBe(releaseOrig); }); - it('returns null for unknown error', async () => { + it('handles unknown error', async () => { s3mock .on(HeadObjectCommand, { Bucket: 'bucket', @@ -859,7 +859,7 @@ describe('modules/datasource/maven/index', () => { releaseOrig, ); - expect(res).toBeNull(); + expect(res).toBe(releaseOrig); }); }); }); diff --git a/lib/modules/datasource/maven/index.ts b/lib/modules/datasource/maven/index.ts index b1443a7d8a1da9..9316ba4f122e66 100644 --- a/lib/modules/datasource/maven/index.ts +++ b/lib/modules/datasource/maven/index.ts @@ -278,7 +278,7 @@ export class MavenDatasource extends Datasource { const res = await checkResource(this.http, artifactUrl); if ( - this.defaultRegistryUrls.includes(registryUrl) && + registryUrl === MAVEN_REPO && (res === 'not-found' || res === 'error') ) { return 'reject';