diff --git a/lib/workers/repository/process/lookup/index.spec.ts b/lib/workers/repository/process/lookup/index.spec.ts index a5efc47f5e06e067a9f5f3661f87c04c8ede48e2..58baa2986886ce24e5b8bd354f9701bc8ba0e15a 100644 --- a/lib/workers/repository/process/lookup/index.spec.ts +++ b/lib/workers/repository/process/lookup/index.spec.ts @@ -14,6 +14,7 @@ import { id as gitVersioningId } from '../../../../modules/versioning/git'; import { id as npmVersioningId } from '../../../../modules/versioning/npm'; import { id as pep440VersioningId } from '../../../../modules/versioning/pep440'; import { id as poetryVersioningId } from '../../../../modules/versioning/poetry'; +import * as githubGraphql from '../../../../util/github/graphql'; import type { LookupUpdateConfig } from './types'; import * as lookup from '.'; @@ -1180,6 +1181,61 @@ describe('workers/repository/process/lookup/index', () => { ); }); + it('should warn if no digest could be found but there is a current digest', async () => { + config.currentValue = 'v1.0.0'; + config.currentDigest = 'bla'; + config.digestOneAndOnly = true; + config.depName = 'angular/angular'; + config.datasource = GithubTagsDatasource.id; + + // Only mock calls once so that the second invocation results in + // no digest being computable. + jest.spyOn(githubGraphql, 'queryReleases').mockResolvedValueOnce([]); + jest.spyOn(githubGraphql, 'queryTags').mockResolvedValueOnce([ + { + version: 'v2.0.0', + gitRef: 'v2.0.0', + releaseTimestamp: '2022-01-01', + hash: 'abc', + }, + ]); + + const res = await lookup.lookupUpdates(config); + expect(res.updates).toHaveLength(0); + expect(res.warnings).toHaveLength(1); + expect(res.warnings[0]).toEqual({ + message: + 'Could not determine new digest for update (datasource: github-tags)', + topic: 'angular/angular', + }); + }); + + describe('pinning enabled but no existing digest', () => { + it('should not warn if no new digest could be found', async () => { + config.currentValue = 'v1.0.0'; + config.digestOneAndOnly = true; + config.depName = 'angular/angular'; + config.pinDigests = true; + config.datasource = GithubTagsDatasource.id; + + // Only mock calls once so that the second invocation results in + // no digest being computable. + jest.spyOn(githubGraphql, 'queryReleases').mockResolvedValueOnce([]); + jest.spyOn(githubGraphql, 'queryTags').mockResolvedValueOnce([ + { + version: 'v2.0.0', + gitRef: 'v2.0.0', + releaseTimestamp: '2022-01-01', + hash: 'abc', + }, + ]); + + const res = await lookup.lookupUpdates(config); + expect(res.updates).toHaveLength(0); + expect(res.warnings).toHaveLength(0); + }); + }); + it('should treat zero zero tilde ranges as 0.0.x', async () => { config.rangeStrategy = 'replace'; config.currentValue = '~0.0.34'; diff --git a/lib/workers/repository/process/lookup/index.ts b/lib/workers/repository/process/lookup/index.ts index 49763a3336b82930ee420bd330e520345c6dc24c..f384524fbac3798818ae10dc1b307e80301823eb 100644 --- a/lib/workers/repository/process/lookup/index.ts +++ b/lib/workers/repository/process/lookup/index.ts @@ -384,6 +384,30 @@ export async function lookupUpdates( // TODO #7154 update.newDigest = update.newDigest ?? (await getDigest(config, update.newValue))!; + + // If the digest could not be determined, report this as otherwise the + // update will be omitted later on without notice. + if (update.newDigest === null) { + logger.debug( + { + depName, + currentValue, + datasource, + newValue: update.newValue, + bucket: update.bucket, + }, + 'Could not determine new digest for update.' + ); + + // Only report a warning if there is a current digest. + // Context: https://github.com/renovatebot/renovate/pull/20175#discussion_r1102615059. + if (currentDigest) { + res.warnings.push({ + message: `Could not determine new digest for update (datasource: ${datasource})`, + topic: depName, + }); + } + } } if (update.newVersion) { const registryUrl = dependency?.releases?.find(