From 394a14048b80453b3bf3bc507a11410ffbca921d Mon Sep 17 00:00:00 2001 From: Erin Schnabel Date: Sat, 8 Jun 2024 16:23:35 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20guard=20against=20NPE=20when=20e?= =?UTF-8?q?rror=20checking?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../automation/github/context/QueryContext.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bot-github-core/src/main/java/org/commonhaus/automation/github/context/QueryContext.java b/bot-github-core/src/main/java/org/commonhaus/automation/github/context/QueryContext.java index 37d4a1d..b9b7107 100644 --- a/bot-github-core/src/main/java/org/commonhaus/automation/github/context/QueryContext.java +++ b/bot-github-core/src/main/java/org/commonhaus/automation/github/context/QueryContext.java @@ -150,8 +150,13 @@ public Throwable bundleExceptions() { public boolean hasNotFound() { return exceptions.stream().anyMatch(e -> e instanceof GHFileNotFoundException) - || errors.stream().anyMatch(e -> e.getOtherFields().containsKey("type") - && e.getOtherFields().get("type").equals("NOT_FOUND")); + || errors.stream().anyMatch(e -> hasFieldError(e, "NOT_FOUND")); + } + + private boolean hasFieldError(GraphQLError e, String message) { + var others = e.getOtherFields(); + var type = others == null ? null : others.get("type"); + return message.equals(type); } public boolean clearNotFound() {