Types of form values are lost when transferred using multipart/form-data

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

Bug Description

Django REST wrappers defined on Horizon's server-side to receive data from Angular modal forms rely on field values being transferred along with their type using JSON format, i.e. number widgets produce '{number_field: 42}', boolean fields produce '{boolean_field: true} etc. This assumption becomes wrong when a FileField is present in such form, because to transfer it browser has to use 'Content-Type: multipart/form-data' header, which forces every field to pass its value as a string.

This becomes a real problem as soon as Glance V2 API is fully supported by Horizon, since Glance V2 requires that image properties types obey the types defined in the schema.

Timur Sufiev (tsufiev-x)
Changed in horizon:
importance: Undecided → High
milestone: none → newton-3
Changed in horizon:
assignee: nobody → Timur Sufiev (tsufiev-x)
status: New → In Progress
Revision history for this message
Timur Sufiev (tsufiev-x) wrote :

The fix is being worked on at https://review.openstack.org/#/c/353987

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to horizon (master)

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

commit f85d2fdbb75618e13d424649aa16231bd9c12ebc
Author: Timur Sufiev <email address hidden>
Date: Thu Aug 11 13:40:36 2016 +0300

    Fix the loss of JSON types when using multipart/form-data

    To pass a binary blob in a POST request, browser sets the header
    'Content-Type: multipart/form-data', which in turn causes all form
    fields' values to be passed as strings. Circumvent this by storing
    original field values as a JSON string on client-side and decoding it
    on server-side. As a result the setting HORIZON_IMAGES_UPLOAD_MODE =
    'legacy' will start working together with Glance V2.

    Closes-Bug: #1613703
    Change-Id: I53a8fbba15e4c3c6c17d6ef1ffe701634efda149

Changed in horizon:
status: In Progress → Fix Released
Revision history for this message
Doug Hellmann (doug-hellmann) wrote : Fix included in openstack/horizon 10.0.0.0b3

This issue was fixed in the openstack/horizon 10.0.0.0b3 development milestone.

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.