diff --git a/lib/api/github.js b/lib/api/github.js index 2cf9df8a38..e60589c8d9 100644 --- a/lib/api/github.js +++ b/lib/api/github.js @@ -163,7 +163,11 @@ async function initRepo(repoName, token, endpoint, repoLogger) { logger.debug('Could not find allowed merge methods for repo'); } } catch (err) /* istanbul ignore next */ { - logger.error(`GitHub init error: ${JSON.stringify(err)}`); + if (err.statusCode === 409) { + logger.debug('Repository is not initiated'); + throw new Error('uninitiated'); + } + logger.error('Unknown GitHub initRepo error'); throw err; } return config; diff --git a/lib/workers/repository/index.js b/lib/workers/repository/index.js index 9c3c4eb2cf..ec67808959 100644 --- a/lib/workers/repository/index.js +++ b/lib/workers/repository/index.js @@ -94,9 +94,14 @@ async function renovateRepository(repoConfig, token) { branchList = ['renovate/configure']; } await cleanup.pruneStaleBranches(config, branchList); - } catch (error) { + } catch (err) { + console.log(JSON.stringify(err)); // Swallow this error so that other repositories can be processed - config.logger.error(`Failed to process repository: ${error.message}`); - config.logger.debug({ error }); + if (err.message === 'uninitiated') { + config.logger.info('Repository is unitiated - skipping'); + } else { + config.logger.error(`Failed to process repository: ${err.message}`); + config.logger.debug({ err }); + } } } diff --git a/test/workers/repository/index.spec.js b/test/workers/repository/index.spec.js index a50f72c1af..e81c6e168c 100644 --- a/test/workers/repository/index.spec.js +++ b/test/workers/repository/index.spec.js @@ -7,14 +7,14 @@ const upgrades = require('../../../lib/workers/repository/upgrades'); const logger = require('../../_fixtures/logger'); -apis.initApis = jest.fn(input => input); -apis.mergeRenovateJson = jest.fn(input => input); -apis.detectPackageFiles = jest.fn(); - describe('workers/repository', () => { describe('renovateRepository', () => { let config; beforeEach(() => { + jest.resetAllMocks(); + apis.initApis = jest.fn(input => input); + apis.mergeRenovateJson = jest.fn(input => input); + apis.detectPackageFiles = jest.fn(); onboarding.getOnboardingStatus = jest.fn(); onboarding.ensurePr = jest.fn(); upgrades.determineRepoUpgrades = jest.fn(() => []); @@ -140,5 +140,18 @@ describe('workers/repository', () => { await repositoryWorker.renovateRepository(config); expect(config.logger.error.mock.calls.length).toBe(1); }); + it('handles special uninitiated error', async () => { + apis.initApis.mockImplementationOnce(() => { + // Create a new object, that prototypically inherits from the Error constructor + function MyError() { + this.message = 'uninitiated'; + } + MyError.prototype = Object.create(Error.prototype); + MyError.prototype.constructor = MyError; + throw new MyError(); + }); + await repositoryWorker.renovateRepository(config); + expect(config.logger.error.mock.calls.length).toBe(0); + }); }); });