JSON Encoder crashes on settings with translations: "ValueError: Circular reference detected"

Bug #1520008 reported by Kyle Olivo
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Dashboard (Horizon)
Invalid
Medium
Unassigned

Bug Description

Description:

Horizon uses the REST_API_REQUIRED_SETTINGS key in the local_settings.py configuration file In order to make the contained configuration available to the the client side angular code.

Some configurations include ugettext objects which fail to serialize when passing through http.

eg.
OPENSTACK_IMAGE_BACKEND = {
    'image_formats': [
        ('aki', _('AKI - Amazon Kernel Image'))
    ]
}

Steps to Reproduce:
* Add 'OPENSTACK_IMAGE_BACKEND' to the 'REST_API_REQUIRED_SETTINGS' key in the local_settings.py.
* call the settings endpoint: http://localhost:8000/api/settings
* Django throws a 500 server exception with the following stack trace: see attached

Impact:
As a workaround, we are setting configuration settings as constants, instead of getting it from the settings service. See
https://review.openstack.org/#/c/236042/22/openstack_dashboard/static/app/core/images/images.module.js

Tags: angularjs
Revision history for this message
Kyle Olivo (kyleolivo) wrote :
Errol Pais (epais)
tags: added: config
removed: configuration horizon translation ugettext
tags: added: configuration
tags: added: translation ugettext
Errol Pais (epais)
description: updated
Revision history for this message
Rob Cresswell (robcresswell-deactivatedaccount) wrote :

I've come across this exact error recently, but not entirely sure how it is triggered.

tags: removed: config configuration translation ugettext
Changed in horizon:
status: New → Confirmed
importance: Undecided → Medium
milestone: none → ongoing
tags: added: angularjs
summary: - JSON Encoder crashes on settings with translations
+ JSON Encoder crashes on settings with translations: "ValueError:
+ Circular reference detected"
Revision history for this message
Rob Cresswell (robcresswell-deactivatedaccount) wrote :

Marked Medium because it doesn't currently cause errors within Horizon, but certainly could prevent proper usage by plugins.

Changed in horizon:
milestone: ongoing → next
Revision history for this message
Matt Borland (palecrow) wrote :

See the changes to settings.py in: https://review.openstack.org/#/c/217828/

I believe this now fixes this specific problem because as the comments show, the exposed object no longer contains lazy-loaded gettext objects. It contains only the keys themselves, which are just strings.

I believe this can be closed. Can anyone concur?

Revision history for this message
Matt Borland (palecrow) wrote :

Rob concurred on IRC.

Changed in horizon:
status: Confirmed → Fix Committed
Changed in horizon:
status: Fix Committed → Invalid
milestone: next → none
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.