diff --git a/lib/util/template/index.ts b/lib/util/template/index.ts
index a449097b3f8ac747986fdba92779f7d6b4383463..92b78ecedce39c1bf650c141cd2cad8c3c1a40e6 100644
--- a/lib/util/template/index.ts
+++ b/lib/util/template/index.ts
@@ -13,7 +13,8 @@ handlebars.registerHelper('stringToPrettyJSON', (input: string): string =>
 // istanbul ignore next
 handlebars.registerHelper(
   'replace',
-  (find, replace, context) => context.replace(new RegExp(find, 'g'), replace) // TODO #12873
+  (find, replace, context) =>
+    (context || '').replace(new RegExp(find, 'g'), replace) // TODO #12873
 );
 
 export const exposedConfigOptions = [