From ef64863f88e398bdd841e6fca5bf6eb90505bfcf Mon Sep 17 00:00:00 2001
From: Michael Kriese <michael.kriese@visualon.de>
Date: Fri, 15 Jul 2022 12:32:12 +0200
Subject: [PATCH] fix(preset/gitlab): manual parse json (#16592)

---
 lib/config/presets/gitlab/index.ts | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lib/config/presets/gitlab/index.ts b/lib/config/presets/gitlab/index.ts
index dfd80bd95d..c0b24f6cf8 100644
--- a/lib/config/presets/gitlab/index.ts
+++ b/lib/config/presets/gitlab/index.ts
@@ -3,8 +3,9 @@ import { logger } from '../../../logger';
 import { ExternalHostError } from '../../../types/errors/external-host-error';
 import type { GitLabBranch } from '../../../types/platform/gitlab';
 import { GitlabHttp } from '../../../util/http/gitlab';
+import type { HttpResponse } from '../../../util/http/types';
 import type { Preset, PresetConfig } from '../types';
-import { PRESET_DEP_NOT_FOUND, fetchPreset } from '../util';
+import { PRESET_DEP_NOT_FOUND, fetchPreset, parsePreset } from '../util';
 
 const gitlabApi = new GitlabHttp();
 export const Endpoint = 'https://gitlab.com/api/v4/';
@@ -36,6 +37,7 @@ export async function fetchJSONFile(
 ): Promise<Preset> {
   let url = endpoint;
   let ref = '';
+  let res: HttpResponse;
   try {
     const urlEncodedRepo = encodeURIComponent(repo);
     const urlEncodedPkgName = encodeURIComponent(fileName);
@@ -50,7 +52,7 @@ export async function fetchJSONFile(
     }
     url += `projects/${urlEncodedRepo}/repository/files/${urlEncodedPkgName}/raw${ref}`;
     logger.trace({ url }, `Preset URL`);
-    return (await gitlabApi.getJson<Preset>(url)).body;
+    res = await gitlabApi.get(url);
   } catch (err) {
     if (err instanceof ExternalHostError) {
       throw err;
@@ -61,6 +63,8 @@ export async function fetchJSONFile(
     );
     throw new Error(PRESET_DEP_NOT_FOUND);
   }
+
+  return parsePreset(res.body);
 }
 
 export function getPresetFromEndpoint(
-- 
GitLab