ceph-validate: avoid "list index out of range" error

Be sure that error.path has more than one members before using them.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
pull/3261/head
Rishabh Dave 2018-10-10 02:17:40 +05:30 committed by mergify[bot]
parent 4d698ce831
commit ff4dc83b87
1 changed files with 6 additions and 1 deletions

View File

@ -102,7 +102,12 @@ class ActionModule(ActionBase):
reason = "[{}] Reason: {}".format(host, error.reason)
try:
if "schema is missing" not in error.message:
given = "[{}] Given value for {}: {}".format(host, error.path[0], error.path[1])
for i in range(0, len(error.path)):
if i == 0:
given = "[{}] Given value for {}".format(
host, error.path[0])
else:
given = given + ": {}".format(error.path[i])
display.error(given)
else:
given = ""