From a65dffc0c7c6699d2e8ebbee7521913ff0c02917 Mon Sep 17 00:00:00 2001 From: Felipe Rodrigues Date: Sun, 12 Feb 2023 23:49:00 -0300 Subject: [PATCH] Fix Manila API error message Some Manila error messages were wrongly returning the string marker "%s" instead of the string content. This patch fixes them. Closes-Bug: #2007060 Change-Id: Ib68f71e19f2ec1190cc431f029d996193008d557 --- manila/api/openstack/wsgi.py | 4 ++-- manila/api/v1/share_types_extra_specs.py | 4 ++-- manila/api/v1/shares.py | 8 ++++---- manila/api/v2/share_group_snapshots.py | 6 +++--- manila/api/v2/share_groups.py | 6 +++--- manila/api/v2/share_instance_export_locations.py | 2 +- manila/api/v2/share_replica_export_locations.py | 2 +- manila/api/v2/share_replicas.py | 14 +++++++------- manila/api/v2/share_types.py | 2 +- ...2007060-fix-error-message-7a34357c0212d8f9.yaml | 6 ++++++ 10 files changed, 30 insertions(+), 24 deletions(-) create mode 100644 releasenotes/notes/bug-2007060-fix-error-message-7a34357c0212d8f9.yaml diff --git a/manila/api/openstack/wsgi.py b/manila/api/openstack/wsgi.py index 3d8d362f88..8bd0bddabf 100644 --- a/manila/api/openstack/wsgi.py +++ b/manila/api/openstack/wsgi.py @@ -744,10 +744,10 @@ class Resource(wsgi.Application): request.set_api_version_request() except exception.InvalidAPIVersionString as e: return Fault(webob.exc.HTTPBadRequest( - explanation=e.message)) + explanation=e.msg)) except exception.InvalidGlobalAPIVersion as e: return Fault(webob.exc.HTTPNotAcceptable( - explanation=e.message)) + explanation=e.msg)) # Identify the action, its arguments, and the requested # content type diff --git a/manila/api/v1/share_types_extra_specs.py b/manila/api/v1/share_types_extra_specs.py index e4e5cfb064..17e0a586de 100644 --- a/manila/api/v1/share_types_extra_specs.py +++ b/manila/api/v1/share_types_extra_specs.py @@ -50,7 +50,7 @@ class ShareTypeExtraSpecsController(wsgi.Controller): try: share_types.get_valid_required_extra_specs(extra_specs) except exception.InvalidExtraSpec as e: - raise webob.exc.HTTPBadRequest(explanation=e.message) + raise webob.exc.HTTPBadRequest(explanation=e.msg) def is_valid_string(v): return isinstance(v, str) and len(v) in range(1, 256) @@ -96,7 +96,7 @@ class ShareTypeExtraSpecsController(wsgi.Controller): try: self._verify_extra_specs(specs, False) except exception.InvalidExtraSpec as e: - raise webob.exc.HTTPBadRequest(e.message) + raise webob.exc.HTTPBadRequest(e.msg) self._check_key_names(specs.keys()) specs = share_types.sanitize_extra_specs(specs) diff --git a/manila/api/v1/shares.py b/manila/api/v1/shares.py index dfb66673b9..3319c0b449 100644 --- a/manila/api/v1/shares.py +++ b/manila/api/v1/shares.py @@ -90,9 +90,9 @@ class ShareMixin(object): except exception.NotFound: raise exc.HTTPNotFound() except exception.InvalidShare as e: - raise exc.HTTPForbidden(explanation=e.message) + raise exc.HTTPForbidden(explanation=e.msg) except exception.Conflict as e: - raise exc.HTTPConflict(explanation=e.message) + raise exc.HTTPConflict(explanation=e.msg) return webob.Response(status_int=http_client.ACCEPTED) @@ -282,14 +282,14 @@ class ShareMixin(object): availability_zone_id = availability_zone_db.id availability_zone = availability_zone_db.name except exception.AvailabilityZoneNotFound as e: - raise exc.HTTPNotFound(explanation=e.message) + raise exc.HTTPNotFound(explanation=e.msg) share_group_id = share.get('share_group_id') if share_group_id: try: share_group = db.share_group_get(context, share_group_id) except exception.ShareGroupNotFound as e: - raise exc.HTTPNotFound(explanation=e.message) + raise exc.HTTPNotFound(explanation=e.msg) sg_az_id = share_group['availability_zone_id'] if availability_zone and availability_zone_id != sg_az_id: msg = _("Share cannot have AZ ('%(s_az)s') different than " diff --git a/manila/api/v2/share_group_snapshots.py b/manila/api/v2/share_group_snapshots.py index 4bf5b0732d..32f6f59b80 100644 --- a/manila/api/v2/share_group_snapshots.py +++ b/manila/api/v2/share_group_snapshots.py @@ -77,7 +77,7 @@ class ShareGroupSnapshotController(wsgi.Controller, wsgi.AdminActionsMixin): self.share_group_api.delete_share_group_snapshot( context, sg_snapshot) except exception.InvalidShareGroupSnapshot as e: - raise exc.HTTPConflict(explanation=e.message) + raise exc.HTTPConflict(explanation=e.msg) return webob.Response(status_int=http_client.ACCEPTED) @wsgi.Controller.api_version('2.31', '2.54', experimental=True) @@ -195,9 +195,9 @@ class ShareGroupSnapshotController(wsgi.Controller, wsgi.AdminActionsMixin): new_snapshot = self.share_group_api.create_share_group_snapshot( context, **kwargs) except exception.ShareGroupNotFound as e: - raise exc.HTTPBadRequest(explanation=e.message) + raise exc.HTTPBadRequest(explanation=e.msg) except exception.InvalidShareGroup as e: - raise exc.HTTPConflict(explanation=e.message) + raise exc.HTTPConflict(explanation=e.msg) return self._view_builder.detail(req, dict(new_snapshot.items())) diff --git a/manila/api/v2/share_groups.py b/manila/api/v2/share_groups.py index 8da1a99398..d0906243b6 100644 --- a/manila/api/v2/share_groups.py +++ b/manila/api/v2/share_groups.py @@ -78,7 +78,7 @@ class ShareGroupController(wsgi.Controller, wsgi.AdminActionsMixin): try: self.share_group_api.delete(context, share_group) except exception.InvalidShareGroup as e: - raise exc.HTTPConflict(explanation=e.message) + raise exc.HTTPConflict(explanation=e.msg) return webob.Response(status_int=http_client.ACCEPTED) @wsgi.Controller.api_version('2.31', '2.54', experimental=True) @@ -241,7 +241,7 @@ class ShareGroupController(wsgi.Controller, wsgi.AdminActionsMixin): kwargs['availability_zone_id'] = az.id kwargs['availability_zone'] = az.name except exception.AvailabilityZoneNotFound as e: - raise exc.HTTPNotFound(explanation=e.message) + raise exc.HTTPNotFound(explanation=e.msg) if 'source_share_group_snapshot_id' in share_group: source_share_group_snapshot_id = share_group.get( @@ -277,7 +277,7 @@ class ShareGroupController(wsgi.Controller, wsgi.AdminActionsMixin): try: new_share_group = self.share_group_api.create(context, **kwargs) except exception.InvalidShareGroupSnapshot as e: - raise exc.HTTPConflict(explanation=e.message) + raise exc.HTTPConflict(explanation=e.msg) except (exception.ShareGroupSnapshotNotFound, exception.InvalidInput) as e: raise exc.HTTPBadRequest(explanation=str(e)) diff --git a/manila/api/v2/share_instance_export_locations.py b/manila/api/v2/share_instance_export_locations.py index aa49cdc80a..d45df2435e 100644 --- a/manila/api/v2/share_instance_export_locations.py +++ b/manila/api/v2/share_instance_export_locations.py @@ -65,7 +65,7 @@ class ShareInstanceExportLocationController(wsgi.Controller): context, export_location_uuid) return self._view_builder.detail(req, export_location) except exception.ExportLocationNotFound as e: - raise exc.HTTPNotFound(explanation=e.message) + raise exc.HTTPNotFound(explanation=e.msg) def create_resource(): diff --git a/manila/api/v2/share_replica_export_locations.py b/manila/api/v2/share_replica_export_locations.py index 3ac01cb22e..e2d0f16db0 100644 --- a/manila/api/v2/share_replica_export_locations.py +++ b/manila/api/v2/share_replica_export_locations.py @@ -85,7 +85,7 @@ class ShareReplicaExportLocationController(wsgi.Controller): return self._view_builder.detail(req, export_location, replica=True) except exception.ExportLocationNotFound as e: - raise exc.HTTPNotFound(explanation=e.message) + raise exc.HTTPNotFound(explanation=e.msg) def create_resource(): diff --git a/manila/api/v2/share_replicas.py b/manila/api/v2/share_replicas.py index 64f6c53cf1..a285225a3b 100644 --- a/manila/api/v2/share_replicas.py +++ b/manila/api/v2/share_replicas.py @@ -56,7 +56,7 @@ class ShareReplicationController(wsgi.Controller, wsgi.AdminActionsMixin): try: self.share_api.delete_share_replica(context, resource, force=True) except exception.ReplicationException as e: - raise exc.HTTPBadRequest(explanation=e.message) + raise exc.HTTPBadRequest(explanation=e.msg) @wsgi.Controller.api_version( MIN_SUPPORTED_API_VERSION, PRE_GRADUATION_VERSION, experimental=True) @@ -199,11 +199,11 @@ class ShareReplicationController(wsgi.Controller, wsgi.AdminActionsMixin): share_network_id=share_network_id, scheduler_hints=scheduler_hints) except exception.AvailabilityZoneNotFound as e: - raise exc.HTTPBadRequest(explanation=e.message) + raise exc.HTTPBadRequest(explanation=e.msg) except exception.ReplicationException as e: - raise exc.HTTPBadRequest(explanation=e.message) + raise exc.HTTPBadRequest(explanation=e.msg) except exception.ShareBusyException as e: - raise exc.HTTPBadRequest(explanation=e.message) + raise exc.HTTPBadRequest(explanation=e.msg) return self._view_builder.detail(req, new_replica) @@ -230,7 +230,7 @@ class ShareReplicationController(wsgi.Controller, wsgi.AdminActionsMixin): try: self.share_api.delete_share_replica(context, replica) except exception.ReplicationException as e: - raise exc.HTTPBadRequest(explanation=e.message) + raise exc.HTTPBadRequest(explanation=e.msg) return webob.Response(status_int=http_client.ACCEPTED) @@ -271,7 +271,7 @@ class ShareReplicationController(wsgi.Controller, wsgi.AdminActionsMixin): try: replica = self.share_api.promote_share_replica(context, replica) except exception.ReplicationException as e: - raise exc.HTTPBadRequest(explanation=e.message) + raise exc.HTTPBadRequest(explanation=e.msg) except exception.AdminRequired as e: raise exc.HTTPForbidden(explanation=e.message) @@ -355,7 +355,7 @@ class ShareReplicationController(wsgi.Controller, wsgi.AdminActionsMixin): try: self.share_api.update_share_replica(context, replica) except exception.InvalidHost as e: - raise exc.HTTPBadRequest(explanation=e.message) + raise exc.HTTPBadRequest(explanation=e.msg) def create_resource(): diff --git a/manila/api/v2/share_types.py b/manila/api/v2/share_types.py index 952c2a00a2..308f5d7783 100644 --- a/manila/api/v2/share_types.py +++ b/manila/api/v2/share_types.py @@ -207,7 +207,7 @@ class ShareTypesController(wsgi.Controller): context, 'share_type.create', share_type) except exception.InvalidExtraSpec as e: - raise webob.exc.HTTPBadRequest(explanation=e.message) + raise webob.exc.HTTPBadRequest(explanation=e.msg) except exception.ShareTypeExists as err: notifier_err = dict(share_types=share_type, error_message=err.message) diff --git a/releasenotes/notes/bug-2007060-fix-error-message-7a34357c0212d8f9.yaml b/releasenotes/notes/bug-2007060-fix-error-message-7a34357c0212d8f9.yaml new file mode 100644 index 0000000000..40c97362ff --- /dev/null +++ b/releasenotes/notes/bug-2007060-fix-error-message-7a34357c0212d8f9.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + Fixed several Manila API error messages with their contents. For more + details, please refer to + `launchpad bug #2007060 `_