diff options
author | Lars Kellogg-Stedman <lars@redhat.com> | 2020-11-02 13:38:47 -0500 |
---|---|---|
committer | Akihiro Motoki <amotoki@gmail.com> | 2021-04-07 13:12:49 +0000 |
commit | bd3fc0de1711177d982245b6409b4b9c6eaac58d (patch) | |
tree | dca653ae7d8d3349b19a2d42e7493c4bc50b2fb6 | |
parent | 35103d9c65a3b00150f13cbe129c1fc13cd120fb (diff) | |
download | horizon-bd3fc0de1711177d982245b6409b4b9c6eaac58d.tar.gz |
handle missing access_rules
we delete the "access_rules" field from the form if keystone API
version is less than 3.13, but we don't consider the case in
clean() method. We are in Wallaby development cycle and we support
N-4 release for upgrade [1]. This means horizon can run with Stein
keystone. Pre-3.13 keystone API (i.e., 3.12) is part of Stein
release [2], so it makes sense to consider this condition.
[1] https://docs.openstack.org/horizon/latest/contributor/policies/supported-software.html
[2] https://docs.openstack.org/api-ref/identity/
Co-Authored-By: Akihiro Motoki <amotoki@gmail.com>
Change-Id: I02e124d90f99d400d8c59bff2c563fdc85e624d4
(cherry picked from commit dadd45addab8fe9ac582f16c3fbc19ff7d81c597)
-rw-r--r-- | openstack_dashboard/dashboards/identity/application_credentials/forms.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/openstack_dashboard/dashboards/identity/application_credentials/forms.py b/openstack_dashboard/dashboards/identity/application_credentials/forms.py index c57132b40..5a8614d86 100644 --- a/openstack_dashboard/dashboards/identity/application_credentials/forms.py +++ b/openstack_dashboard/dashboards/identity/application_credentials/forms.py @@ -132,12 +132,15 @@ class CreateApplicationCredentialForm(forms.SelfHandlingForm): def clean(self): cleaned_data = super().clean() - try: - cleaned_data['access_rules'] = yaml.safe_load( - cleaned_data['access_rules']) - except yaml.YAMLError: - msg = (_('Access rules must be a valid JSON or YAML list.')) - raise forms.ValidationError(msg) + # access_rules field exists only when keystone API >= 3.13 and + # the field is deleted above when a lower version of API is used. + if 'access_rules' in cleaned_data: + try: + cleaned_data['access_rules'] = yaml.safe_load( + cleaned_data['access_rules']) + except yaml.YAMLError: + msg = (_('Access rules must be a valid JSON or YAML list.')) + raise forms.ValidationError(msg) return cleaned_data |