diff --git a/lib/workers/repository/dependency-dashboard.spec.ts b/lib/workers/repository/dependency-dashboard.spec.ts index 054eef3f32be5597ad5074c79f9b7a0da85fabdc..659ee4daafeca085d505bf64c207f02158979df7 100644 --- a/lib/workers/repository/dependency-dashboard.spec.ts +++ b/lib/workers/repository/dependency-dashboard.spec.ts @@ -92,6 +92,26 @@ async function dryRun( describe('workers/repository/dependency-dashboard', () => { describe('readDashboardBody()', () => { + it('parses invalid dashboard body without throwing error', async () => { + const conf: RenovateConfig = {}; + conf.prCreation = 'approval'; + platform.findIssue.mockResolvedValueOnce({ + title: '', + number: 1, + body: null as never, + }); + await dependencyDashboard.readDashboardBody(conf); + expect(conf).toEqual({ + dependencyDashboardChecks: {}, + dependencyDashboardAllPending: false, + dependencyDashboardAllRateLimited: false, + dependencyDashboardIssue: 1, + dependencyDashboardRebaseAllOpen: false, + dependencyDashboardTitle: 'Dependency Dashboard', + prCreation: 'approval', + }); + }); + it('reads dashboard body', async () => { const conf: RenovateConfig = {}; conf.prCreation = 'approval'; diff --git a/lib/workers/repository/dependency-dashboard.ts b/lib/workers/repository/dependency-dashboard.ts index e3ceff94865e8e71e150c47b5549b521f5952fdc..54ff00693f23f00df873d87ebb9d5b2fc1ef9b49 100644 --- a/lib/workers/repository/dependency-dashboard.ts +++ b/lib/workers/repository/dependency-dashboard.ts @@ -76,7 +76,8 @@ function getAllSelectedBranches( function getCheckedBranches(issueBody: string): Record<string, string> { let dependencyDashboardChecks: Record<string, string> = {}; - for (const [, type, branchName] of issueBody.matchAll(markedBranchesRe)) { + for (const [, type, branchName] of issueBody?.matchAll(markedBranchesRe) ?? + []) { dependencyDashboardChecks[branchName] = type; } dependencyDashboardChecks = getAllSelectedBranches( @@ -115,7 +116,7 @@ export async function readDashboardBody( const issue = await platform.findIssue(config.dependencyDashboardTitle); if (issue) { config.dependencyDashboardIssue = issue.number; - const dashboardChecks = parseDashboardIssue(issue.body!); + const dashboardChecks = parseDashboardIssue(issue.body ?? ''); if (config.checkedBranches) { const checkedBranchesRec: Record<string, string> = Object.fromEntries( @@ -436,7 +437,7 @@ export async function ensureDependencyDashboard( ); if (updatedIssue) { const { dependencyDashboardChecks } = parseDashboardIssue( - updatedIssue.body! + updatedIssue.body ?? '' ); for (const branchName of Object.keys(config.dependencyDashboardChecks!)) { delete dependencyDashboardChecks[branchName];