Skip to content

Commit 0d501cb

Browse files
authored
Prevent unclear Elasticsearch alias update failures when response is malformed (#1060)
Add explicit check for missing "acknowledged" key in Elasticsearch response Bug: T418143
1 parent 8e60bc6 commit 0d501cb

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

app/Jobs/ElasticSearchAliasInit.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,14 @@ public function handle(HttpRequest $request) {
112112
}
113113

114114
$json = json_decode($rawResponse, true);
115+
if (!array_key_exists('acknowledged', $json)) {
116+
Log::error("Missing 'acknowledged' key. Are the shared indices set up properly?");
117+
$this->fail(
118+
new \RuntimeException("Updating Elasticsearch aliases failed for $this->wikiId with $rawResponse")
119+
);
120+
121+
return;
122+
}
115123
if ($json['acknowledged'] !== true) {
116124
Log::error(__METHOD__ . ": Updating Elasticsearch aliases failed for $this->wikiId with $rawResponse");
117125
$this->fail(

0 commit comments

Comments
 (0)