Skip to content

Commit

Permalink
[ML] Fixing update datafeed endpoint (elastic#119515)
Browse files Browse the repository at this point in the history
* [ML] Fixing update datafeed endpoint

* adding comments

* using internal user

* updating comment
  • Loading branch information
jgowdyelastic authored and TinLe committed Dec 22, 2021
1 parent 724d16b commit 17570fa
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion x-pack/plugins/ml/server/lib/ml_client/ml_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,24 @@ export function getMlClient(
},
async updateDatafeed(...p: Parameters<MlClient['updateDatafeed']>) {
await datafeedIdsCheck(p);
return mlClient.updateDatafeed(...p);

// Temporary workaround for the incorrect updateDatafeed function in the esclient
if (p.length === 0 || p[0] === undefined) {
// Temporary generic error message. This should never be triggered
// but is added for type correctness below
throw new Error('Incorrect arguments supplied');
}
const { datafeed_id: id, body } = p[0];

return client.asInternalUser.transport.request({
method: 'POST',
path: `/_ml/datafeeds/${id}/_update`,
body,
});

// this should be reinstated once https://github.com/elastic/elasticsearch-js/issues/1601
// is fixed
// return mlClient.updateDatafeed(...p);
},
async updateFilter(...p: Parameters<MlClient['updateFilter']>) {
return mlClient.updateFilter(...p);
Expand Down

0 comments on commit 17570fa

Please sign in to comment.