strutils: mask_password: TypeError: cannot concatenate 'str' and 'Request' objects

Bug #1413677 reported by Amrith Kumar
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack DBaaS (Trove)
Fix Released
High
Amrith Kumar

Bug Description

Seen in trove gate as part of change https://review.openstack.org/#/c/141880/

to resync oslo-incubator code.

2015-01-22 15:33:12.887 | trove.common.wsgi: DEBUG: Getting schema for type:create
2015-01-22 15:33:12.887 | trove.common.wsgi: DEBUG: Found Schema: none
2015-01-22 15:33:12.888 | trove.instance.service: INFO: Creating a database instance for tenant '2500'
2015-01-22 15:33:12.888 | trove.common.wsgi: ERROR: 3d2cd540-6194-4d8d-a66a-fc67e8891068: cannot concatenate 'str' and 'Request' objects
2015-01-22 15:33:12.888 | 2015-01-22 15:33:10.439 4738 TRACE trove.common.wsgi Traceback (most recent call last):
2015-01-22 15:33:12.888 | 2015-01-22 15:33:10.439 4738 TRACE trove.common.wsgi File "/home/jenkins/workspace/gate-trove-python27/trove/common/wsgi.py", line 251, in execute_action
2015-01-22 15:33:12.888 | 2015-01-22 15:33:10.439 4738 TRACE trove.common.wsgi **action_args)
2015-01-22 15:33:12.888 | 2015-01-22 15:33:10.439 4738 TRACE trove.common.wsgi File "/home/jenkins/workspace/gate-trove-python27/trove/common/base_wsgi.py", line 393, in execute_action
2015-01-22 15:33:12.888 | 2015-01-22 15:33:10.439 4738 TRACE trove.common.wsgi return self.dispatch(self.controller, action, request, **action_args)
2015-01-22 15:33:12.888 | 2015-01-22 15:33:10.439 4738 TRACE trove.common.wsgi File "/home/jenkins/workspace/gate-trove-python27/trove/common/base_wsgi.py", line 402, in dispatch
2015-01-22 15:33:12.888 | 2015-01-22 15:33:10.439 4738 TRACE trove.common.wsgi return method(*args, **kwargs)
2015-01-22 15:33:12.888 | 2015-01-22 15:33:10.439 4738 TRACE trove.common.wsgi File "/home/jenkins/workspace/gate-trove-python27/trove/instance/service.py", line 189, in create
2015-01-22 15:33:12.888 | 2015-01-22 15:33:10.439 4738 TRACE trove.common.wsgi LOG.debug(strutils.mask_password("req : '%s'\n\n", req))
2015-01-22 15:33:12.889 | 2015-01-22 15:33:10.439 4738 TRACE trove.common.wsgi File "/home/jenkins/workspace/gate-trove-python27/.tox/py27/local/lib/python2.7/site-packages/oslo_utils/strutils.py", line 240, in mask_password
2015-01-22 15:33:12.889 | 2015-01-22 15:33:10.439 4738 TRACE trove.common.wsgi substitute1 = r'\g<1>' + secret
2015-01-22 15:33:12.889 | 2015-01-22 15:33:10.439 4738 TRACE trove.common.wsgi TypeError: cannot concatenate 'str' and 'Request' objects
2015-01-22 15:33:12.889 | 2015-01-22 15:33:10.439 4738 TRACE trove.common.wsgi
2015-01-22 15:33:12.889 | troveclient.compat.client: DEBUG: REQ: curl -i http://localhost:8779/v1.0/2500/instances -X POST -H "Content-Type: application/json" -H "X-Auth-Project-Id: 2500" -H "User-Agent: python-troveclient" -H "X-Auth-Token: 2500" -H "Accept: application/json"
2015-01-22 15:33:12.889 |
2015-01-22 15:33:12.889 | troveclient.compat.client: DEBUG: REQ BODY: {"instance": {"volume": {"size": 1}, "flavorRef": 1, "name": "TEST_2015-01-22 15:33:10.433332"}}
2015-01-22 15:33:12.889 |
2015-01-22 15:33:12.889 | troveclient.compat.client: DEBUG: RESP:{'status': '500', 'content-length': '168', 'content-type': 'application/json; charset=UTF-8'} {"instanceFault": {"code": 500, "message": "Internal Server Error. Please keep this ID to help us figure out what went wrong: (3d2cd540-6194-4d8d-a66a-fc67e8891068)."}}

Amrith Kumar (amrith)
Changed in oslo.utils:
assignee: nobody → Amrith (amrith)
Revision history for this message
Ben Nemec (bnemec) wrote :

The call causing the exception is this:

LOG.debug(logging.mask_password("req : '%s'\n\n", req))

Which is not the correct way to call mask_password. This happened to "work" before due to some implementation details in mask_password, but after some recent refactoring that is no longer true. Note that when I say "work", I mean complete without exception. It wasn't actually masking any passwords because the string it was working on was the format string for the log message, not the content.

The correct code to do this looks like:

LOG.debug("req : '%s'\n\n", logging.mask_password(req))

That will mask any passwords in req, then pass it as a parameter to the logging function.

Changed in oslo.utils:
status: New → Invalid
Revision history for this message
Amrith Kumar (amrith) wrote :

Thanks Ben, I'll move this over to Trove and fix it there.

affects: oslo.utils → trove
Changed in trove:
status: Invalid → Triaged
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to trove (master)

Fix proposed to branch: master
Review: https://review.openstack.org/149369

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

Reviewed: https://review.openstack.org/149369
Committed: https://git.openstack.org/cgit/openstack/trove/commit/?id=53213dea1f743a8baa94c2bd9b3994ef191c449e
Submitter: Jenkins
Branch: master

commit 53213dea1f743a8baa94c2bd9b3994ef191c449e
Author: Amrith Kumar <email address hidden>
Date: Thu Jan 22 14:04:58 2015 -0500

    Correct calls to mask_password() which no longer work

    There were some places in the code where the mask_password() routine
    was being called incorrectly and these now resulted in a failure due
    to a newer version of oslo.utils (strutils).

    I've fixed the one location which was causing the reported failure and
    seven other places where the same incorrect code was present.

    Change-Id: I69f47806f1552358071b031a9ef68f016df0e7c2
    Closes-Bug: 1413677

Changed in trove:
status: In Progress → Fix Committed
Changed in trove:
importance: Undecided → High
milestone: none → kilo-2
Thierry Carrez (ttx)
Changed in trove:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in trove:
milestone: kilo-2 → 2015.1.0
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.