InstanceDetailTests::test_instance_details_metadata fails in Django 4.2

Bug #2040129 reported by Akihiro Motoki
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Dashboard (Horizon)
Fix Released
High
Akihiro Motoki

Bug Description

openstack_dashboard/dashboards/project/instances/tests.py::InstanceDetailTests::test_instance_details_metadata fails with Django 4.2.

https://paste.opendev.org/show/b1shjdi1CWeXZMuPEyEY/

Failure example is found at
https://zuul.opendev.org/t/openstack/build/2b2cf8974891413091929f214a05970e/log/job-output.txt#39829-39856

Tags: unittest
Revision history for this message
Akihiro Motoki (amotoki) wrote :

The rendered HTMl outputs of "Metadata" section are different in Django 3.2 and 4.2.

Django 3.2
---
        <dt>someMetaLabel</dt>
        <dd>someMetaData</dd>

        <dt>some<b>html</b>label</dt>
        <dd><!--</dd>

        <dt>empty</dt>
        <dd><em>N/A</em></dd>
---

Django 4.2
---
        <dt>someMetaLabel</dt>
        <dd>someMetaData</dd>

        <dt>some<b>html</b>label</dt>
        <dd><!--</dd>

        <dt>empty</dt>
        <dd></em></dd>
---

Revision history for this message
Akihiro Motoki (amotoki) wrote :

Looking at the corresponing template [1], L.149 does the magic for the default value when a value is empty. I am afraid this is an undocument/unspecified behavior and it was changed in Django 4.2 (or 4.x series).
Perhaps it is better to use {% if %} clause rather than this magic.

[1] https://opendev.org/openstack/horizon/src/branch/master/openstack_dashboard/dashboards/project/instances/templates/instances/_detail_overview.html#L149-L153

Changed in horizon:
assignee: nobody → Akihiro Motoki (amotoki)
status: New → Triaged
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to horizon (master)

Fix proposed to branch: master
Review: https://review.opendev.org/c/openstack/horizon/+/899021

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

Reviewed: https://review.opendev.org/c/openstack/horizon/+/899021
Committed: https://opendev.org/openstack/horizon/commit/5c61331ff229b4e9e8b51c6335cd1895b90fdfa0
Submitter: "Zuul (22348)"
Branch: master

commit 5c61331ff229b4e9e8b51c6335cd1895b90fdfa0
Author: Akihiro Motoki <email address hidden>
Date: Mon Oct 23 15:36:49 2023 +0900

    Django 4.2: Adjust instance detail template

    The template for the instance detail overview uses Django template
    filters to define a default value for metadata with an empty value.
    This usage looks magic and does not work with Django 4.2.
    It looks like this is an undocumented/unspecified behavior.
    This commit changes it to use {% if %} template syntax instead of
    depending on the unspcified behavior.

    Closes-Bug: #2040129
    Change-Id: Ida5b2a721f2657347c174e386d2e023dffd64b1b

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

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