TypeError in message logging

Bug #1659342 reported by Gábor Antal
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Dashboard (Horizon)
Fix Released
Low
Gábor Antal

Bug Description

In openstack_dashboard/api/neutron.py [1], There is a wrongly rewritten message logging, which trows TypeError instead of logging. This code was merged a long time ago [2].

The lines are the following:
        LOG.debug("router_static_route_list(): router_id=%s, "
                  "router=%s", (router_id, router))

Which I think wanted to be the following:
        LOG.debug("router_static_route_list(): router_id=%s, "
                  "router=%s" % (router_id, router))

But since there is a guideline to delay the string interpolation and leave it to the logger, it should be something like this (or add names, that would be more elegant):
        LOG.debug("router_static_route_list(): router_id=%s, "
                  "router=%s", router_id, router)

[1]: https://github.com/openstack/horizon/blob/master/openstack_dashboard/api/neutron.py#L1079
[2]: https://review.openstack.org/#/c/135890/

Changed in horizon:
assignee: nobody → Gábor Antal (gabor.antal)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to horizon (master)

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

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

Reviewed: https://review.openstack.org/425262
Committed: https://git.openstack.org/cgit/openstack/horizon/commit/?id=41ee8c0677b69f7d76092d76465d6f318e74c8b9
Submitter: Jenkins
Branch: master

commit 41ee8c0677b69f7d76092d76465d6f318e74c8b9
Author: Gábor Antal <email address hidden>
Date: Wed Jan 25 16:36:48 2017 +0100

    Fix TypeError in api/neutron.py

    In api/neutron.py [1], there is a logging, which throws a TypeError,
    because the arguments of the format message is passed as a tuple,
    which is not working when you pass the arguments to the logger,
    instead of replacing in-place. In the current code, running the log
    message leds to the following:

    TypeError: not enough arguments for format string
    Call stack:
      File "test.py", line 9, in <module>
        "router=%s", (router_id, router))
    Message: 'router_static_route_list(): router_id=%s, router=%s'
    Arguments: (('asd', 'asdf'),)

    In this patchset, this bug is fixed.

    [1]: https://github.com/openstack/horizon/blob/master/openstack_dashboard/api/neutron.py#L1079

    Change-Id: I233c435bb7ca89c6c8ecd49a66bccb5b59eedf41
    Closes-Bug: #1659342

Changed in horizon:
status: In Progress → Fix Released
Changed in horizon:
milestone: none → ocata-rc1
tags: added: newton-backport-potential
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to horizon (stable/newton)

Fix proposed to branch: stable/newton
Review: https://review.openstack.org/426845

Changed in horizon:
importance: Undecided → Low
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to horizon (stable/newton)

Reviewed: https://review.openstack.org/426845
Committed: https://git.openstack.org/cgit/openstack/horizon/commit/?id=84693cada5f9c6ad548842a2b8e3354f1ca45981
Submitter: Jenkins
Branch: stable/newton

commit 84693cada5f9c6ad548842a2b8e3354f1ca45981
Author: Gábor Antal <email address hidden>
Date: Wed Jan 25 16:36:48 2017 +0100

    Fix TypeError in api/neutron.py

    In api/neutron.py [1], there is a logging, which throws a TypeError,
    because the arguments of the format message is passed as a tuple,
    which is not working when you pass the arguments to the logger,
    instead of replacing in-place. In the current code, running the log
    message leds to the following:

    TypeError: not enough arguments for format string
    Call stack:
      File "test.py", line 9, in <module>
        "router=%s", (router_id, router))
    Message: 'router_static_route_list(): router_id=%s, router=%s'
    Arguments: (('asd', 'asdf'),)

    In this patchset, this bug is fixed.

    [1]: https://github.com/openstack/horizon/blob/master/openstack_dashboard/api/neutron.py#L1079

    Change-Id: I233c435bb7ca89c6c8ecd49a66bccb5b59eedf41
    Closes-Bug: #1659342
    (cherry picked from commit 41ee8c0677b69f7d76092d76465d6f318e74c8b9)

tags: added: in-stable-newton
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/horizon 11.0.0.0rc1

This issue was fixed in the openstack/horizon 11.0.0.0rc1 release candidate.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/horizon 10.0.3

This issue was fixed in the openstack/horizon 10.0.3 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.