``Backend._ensure_backend_available`` converts the URL object to string

Bug #2012928 reported by Rodolfo Alonso
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
oslo.db
Fix Released
Undecided
Unassigned

Bug Description

In [1], ``Backend._ensure_backend_available`` is converting a ``url.URL`` to string to then parse it again to obtain a ``url.URL`` object again.

* Before SQLAlchemy 2.0, the ``URL.__str__`` method was calling "render_as_string" method with "hide_password=False".
* In SQLAlchemy 2.0 [3], the `URL.__str__`` doesn't exist and `URL.__repr__`` is called instead. However, in this case the password is hidden. That means the new URL object created has the string "***" as password instead of the original string.

This issue has been detected in the Neutron experimental CI, in the "neutron-functional-with-sqlalchemy-master" job [4].

[1]https://github.com/openstack/oslo.db/blob/94d6e24ca19b0116eed00d5ccdb8a538918c6dcf/oslo_db/sqlalchemy/provision.py#L262
[2]https://github.com/sqlalchemy/sqlalchemy/blob/cdad8ab375ab5d04c52f7be7ce1c85f588d8355e/lib/sqlalchemy/engine/url.py#L559
[3]https://github.com/sqlalchemy/sqlalchemy/blob/c7ce7ff0225fe0ddaf63f0706429b885410de365/lib/sqlalchemy/engine/url.py#L610
[4]https://fa67ce491574b958f29b-7b9374470c0105283123d1c69dc66ebe.ssl.cf2.rackcdn.com/878526/1/experimental/neutron-functional-with-sqlalchemy-master/cc86a0a/testr_results.html

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to oslo.db (master)

Fix proposed to branch: master
Review: https://review.opendev.org/c/openstack/oslo.db/+/878642

Changed in oslo.db:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to oslo.db (master)

Reviewed: https://review.opendev.org/c/openstack/oslo.db/+/878642
Committed: https://opendev.org/openstack/oslo.db/commit/da4f13e7345653eba8aab5b8aceeaeff7367989e
Submitter: "Zuul (22348)"
Branch: master

commit da4f13e7345653eba8aab5b8aceeaeff7367989e
Author: Rodolfo Alonso Hernandez <email address hidden>
Date: Mon Mar 27 15:12:06 2023 +0200

    Do not convert to string ``url.URL`` objects

    The SQLAlchemy method ``url.make_url`` accepts strings and ``url.URL``
    object types. By default, oslo.db was converting any object to string
    before calling ``url.make_url``, that parses this string. Since
    SQLAlchemy 2.0, the ``url.URL.__str__`` method is removed and the
    ``url.URL.__repr__`` method returns a string with the password hidden.

    The new utility method checks what type of object is passed and only
    if the object is not a string nor a ``url.URL`` object, is converted
    to a string.

    Closes-Bug: #2012928
    Change-Id: I84f13f378f83e2a55078370ae2b4787f00982c23

Changed in oslo.db:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/oslo.db 13.0.0

This issue was fixed in the openstack/oslo.db 13.0.0 release.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.