Skip to content

Commit

Permalink
Raise error if 'policy' field missing in create-ilm operation body (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
b-deam authored Nov 15, 2023
1 parent 20a4427 commit 69e917d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion esrally/driver/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -2682,7 +2682,17 @@ class CreateIlmPolicy(Runner):
async def __call__(self, es, params):
policy_name = mandatory(params, "policy-name", self)
body = mandatory(params, "body", self)
policy = mandatory(body, "policy", self)
policy = body.get("policy", {})

if not policy:
# The es client automatically inserts the runner's 'body' within a top level a 'policy' field, so if a user
# provides a 'body' missing the 'policy' field, the request fails with a misleading exception message, so
# let's raise a more helpful error message.
raise exceptions.DataError(
"Request body does not contain the expected root field [policy]. Please ensure that the request body contains "
"a top-level 'policy' field and try again."
)

request_params = params.get("request-params", {})
error_trace = request_params.get("error_trace", None)
filter_path = request_params.get("filter_path", None)
Expand Down

0 comments on commit 69e917d

Please sign in to comment.