Skip to content

Commit

Permalink
fix(bitbucket): Log when Bitbucket event unknown (#581)
Browse files Browse the repository at this point in the history
* fix(bitbucket): Log when Bitbucket event unknown

There are rare cases (often when the /bitbucket endpoint is used instead
of /stash) where the bitbucket event type doesn't match _either_ the
Cloud or Server types; this can cause an NPE in the subsequent log
message because "branch" doesn't get set (this was also fixed, although
should probably not happen any more).  In this case, we log the fact
that we couldn't determine the Cloud/Server type based on the event_type
(noting the event_type we _did_ get) and return.

* Run spotlessApply
  • Loading branch information
dotdotdotpaul authored and cfieber committed Jun 20, 2019
1 parent 8879064 commit 7c95141
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ public void handle(Event event, Map postedEvent) {
handleBitbucketCloudEvent(event, postedEvent);
} else if (looksLikeBitbucketServer(event)) {
handleBitbucketServerEvent(event, postedEvent);
} else {
// Could not determine what type of Bitbucket event this was.
log.info(
"Could not determine Bitbucket type {}",
kv("event_type", event.content.get("event_type")));
return;
}

String fullRepoName = getFullRepoName(event);
Expand Down Expand Up @@ -98,7 +104,9 @@ public void handle(Event event, Map postedEvent) {
event.content.containsKey("request_id")
? event.content.get("request_id").toString()
: ""),
kv("branch", event.content.get("branch").toString()));
kv(
"branch",
event.content.containsKey("branch") ? event.content.get("branch").toString() : ""));
}
}

Expand Down

0 comments on commit 7c95141

Please sign in to comment.