From 58a6d645e805bf18abea838e67ef7e25d06805b2 Mon Sep 17 00:00:00 2001
From: Rhys Arkins <rhys@arkins.net>
Date: Wed, 11 Jan 2023 18:13:25 +0100
Subject: [PATCH] fix(terraform): try/catch HCL parsing (#19792)

---
 lib/modules/manager/terraform/hcl/index.ts | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/modules/manager/terraform/hcl/index.ts b/lib/modules/manager/terraform/hcl/index.ts
index 9598e001c6..576d8de1c5 100644
--- a/lib/modules/manager/terraform/hcl/index.ts
+++ b/lib/modules/manager/terraform/hcl/index.ts
@@ -1,7 +1,11 @@
 import * as hcl_parser from 'hcl2-parser';
 
 export function parseHCL(content: string): any {
-  return hcl_parser.parseToObject(content)[0];
+  try {
+    return hcl_parser.parseToObject(content)[0];
+  } catch (err) /* istanbul ignore next */ {
+    return null;
+  }
 }
 
 export function parseJSON(content: string): any {
-- 
GitLab