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
This commit is contained in:
Artom Lifshitz
2024-08-09 13:52:01 -04:00
parent 7399728e89
commit 751c2e8b8b
+1 -1
View File
@@ -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)