qapi: Tweak error messages for unknown / conflicting 'if' keys
authorMarkus Armbruster <armbru@redhat.com>
Tue, 31 Aug 2021 12:38:09 +0000 (14:38 +0200)
committerMarkus Armbruster <armbru@redhat.com>
Fri, 3 Sep 2021 15:09:10 +0000 (17:09 +0200)
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20210831123809.1107782-13-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
scripts/qapi/expr.py
tests/qapi-schema/bad-if-key.err
tests/qapi-schema/bad-if-keys.err
tests/qapi-schema/enum-if-invalid.err

index ae4437ba08e5af7524b2dc6b1a34bae821159410..b62f0a3640632e474e3562823126f661f5696836 100644 (file)
@@ -286,13 +286,12 @@ def check_if(expr: _JSONObject, info: QAPISourceInfo, source: str) -> None:
             raise QAPISemError(
                 info,
                 "'if' condition of %s must be a string or an object" % source)
+        check_keys(cond, info, "'if' condition of %s" % source, [],
+                   ["all", "any", "not"])
         if len(cond) != 1:
             raise QAPISemError(
                 info,
-                "'if' condition dict of %s must have one key: "
-                "'all', 'any' or 'not'" % source)
-        check_keys(cond, info, "'if' condition", [],
-                   ["all", "any", "not"])
+                "'if' condition of %s has conflicting keys" % source)
 
         oper, operands = next(iter(cond.items()))
         if not operands:
index a69dc9ee86e21e2cc9acbf6a3ed02aaf6021d96e..38cf44b68758f7acbd18c30ff0923a522bbfdda4 100644 (file)
@@ -1,3 +1,3 @@
 bad-if-key.json: In struct 'TestIfStruct':
-bad-if-key.json:2: 'if' condition has unknown key 'value'
+bad-if-key.json:2: 'if' condition of struct has unknown key 'value'
 Valid keys are 'all', 'any', 'not'.
index aceb31dc6dde20d2da0f91160ff2e9782d87771f..fe87bd30aca77c859e81625a2bd16e589ac4eb9b 100644 (file)
@@ -1,2 +1,2 @@
 bad-if-keys.json: In struct 'TestIfStruct':
-bad-if-keys.json:2: 'if' condition dict of struct must have one key: 'all', 'any' or 'not'
+bad-if-keys.json:2: 'if' condition of struct has conflicting keys
index 3bb84075a90f1a7aa45e882f5693f1ee9dfe4aae..2b2bbffb65b2d50d0e8bfa9738a46e0f7d19e462 100644 (file)
@@ -1,3 +1,3 @@
 enum-if-invalid.json: In enum 'TestIfEnum':
-enum-if-invalid.json:2: 'if' condition has unknown key 'val'
+enum-if-invalid.json:2: 'if' condition of 'data' member 'bar' has unknown key 'val'
 Valid keys are 'all', 'any', 'not'.