From 751c2e8b8bbc4eac82d593854ef08b5fd2bb8ffb Mon Sep 17 00:00:00 2001 From: Artom Lifshitz Date: Fri, 9 Aug 2024 13:52:01 -0400 Subject: [PATCH] Fix s/addtional/additional/ typo The typo'ed spelling is only used in _strip_additional_query_parameters(), which is as the name implies, removes from the request any keys that are not present in the schema. The nuance is that this happens only _after_ calling the _schema_validation_helper() (which actually validates the request against the schema), and _only_ if the validation succeeds. So while yes, _strip_additional_query_parameters() erroneously tried to find 'addtionalProperties' in the schema, never found it, always defaulted to True, and proceed to unconditionally strip any keys not found in the schema, this was never a problem: the validation had already been done, and if additionalProperties was False, the validation correctly failed if extra keys were present. Which means that if the code flow ever got to _strip_additional_query_parameters() _with_ extra keys present in the request, it means additionalProperties was True anyways, and it made no material difference. And I hate that I spent over an hour trying to understand why this typo makes no difference in unit tests of behaviour. Change-Id: I1ba5b9fa2ec5e4021543021068625d61ee671cdb --- nova/api/validation/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/api/validation/__init__.py b/nova/api/validation/__init__.py index 9d581e2d53..3c8a18183f 100644 --- a/nova/api/validation/__init__.py +++ b/nova/api/validation/__init__.py @@ -124,7 +124,7 @@ def _strip_additional_query_parameters(schema, req): the JSON-Schema validation. It also means this method only can be called after _schema_validation_helper return `True`. """ - additional_properties = schema.get('addtionalProperties', True) + additional_properties = schema.get('additionalProperties', True) pattern_regexes = [] patterns = schema.get('patternProperties', None)