From 1ab9b09d41b20347681058b240b40a482f49ac7d Mon Sep 17 00:00:00 2001
From: Rhys Arkins <rhys@arkins.net>
Date: Tue, 11 Sep 2018 10:14:29 +0200
Subject: [PATCH] fix(github): catch empty graphql data

---
 lib/platform/github/index.js | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/lib/platform/github/index.js b/lib/platform/github/index.js
index 4a10f231f1..e85a1055e5 100644
--- a/lib/platform/github/index.js
+++ b/lib/platform/github/index.js
@@ -890,6 +890,11 @@ async function getOpenPrs() {
       };
       const res = JSON.parse((await get.post(url, options)).body);
       const prNumbers = [];
+      // istanbul ignore if
+      if (!res.data) {
+        logger.warn({ res }, 'No graphql res.data');
+        return {};
+      }
       for (const pr of res.data.repository.pullRequests.nodes) {
         // https://developer.github.com/v4/object/pullrequest/
         pr.displayNumber = `Pull Request #${pr.number}`;
@@ -986,6 +991,11 @@ async function getClosedPrs() {
       };
       const res = JSON.parse((await get.post(url, options)).body);
       const prNumbers = [];
+      // istanbul ignore if
+      if (!res.data) {
+        logger.warn({ res }, 'No graphql res.data');
+        return {};
+      }
       for (const pr of res.data.repository.pullRequests.nodes) {
         // https://developer.github.com/v4/object/pullrequest/
         pr.displayNumber = `Pull Request #${pr.number}`;
-- 
GitLab