Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions superset/views/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2962,7 +2962,9 @@ def welcome(self):
return self.render_template(
"superset/basic.html",
entry="welcome",
bootstrap_data=json.dumps(payload, default=utils.json_iso_dttm_ser),
bootstrap_data=json.dumps(
payload, default=utils.pessimistic_json_iso_dttm_ser
),
)

@has_access
Expand Down Expand Up @@ -3001,7 +3003,7 @@ def sqllab(self):
return self.render_template(
"superset/basic.html",
entry="sqllab",
bootstrap_data=json.dumps(d, default=utils.json_iso_dttm_ser),
bootstrap_data=json.dumps(d, default=utils.pessimistic_json_iso_dttm_ser),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels weird to be passing variant/loosely-typed data to this but I guess Superset does that a lot so I won't complain much other than to point it out. :-)

)

@api
Expand Down
20 changes: 20 additions & 0 deletions tests/core_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# specific language governing permissions and limitations
# under the License.
"""Unit tests for Superset"""
import cgi
import csv
import datetime
import doctest
Expand Down Expand Up @@ -949,6 +950,25 @@ def test_results_msgpack_deserialization(self):
self.assertDictEqual(deserialized_payload, payload)
expand_data.assert_called_once()

@mock.patch.dict("superset._feature_flags", {"FOO": lambda x: 1}, clear=True)
def test_feature_flag_serialization(self):
"""
Functions in feature flags don't break bootstrap data serialization.
"""
self.login()

encoded = json.dumps(
{"FOO": lambda x: 1, "super": "set"},
default=utils.pessimistic_json_iso_dttm_ser,
)
html = cgi.escape(encoded).replace("'", "'").replace('"', """)

data = self.get_resp("/superset/sqllab")
self.assertTrue(html in data)

data = self.get_resp("/superset/welcome")
self.assertTrue(html in data)


if __name__ == "__main__":
unittest.main()