Skip to content

Comments

Encode feature flags to JSON pessimistically#8529

Merged
betodealmeida merged 3 commits intoapache:masterfrom
lyft:encode_ff_pessimist
Nov 12, 2019
Merged

Encode feature flags to JSON pessimistically#8529
betodealmeida merged 3 commits intoapache:masterfrom
lyft:encode_ff_pessimist

Conversation

@betodealmeida
Copy link
Member

CATEGORY

Choose one

  • Bug Fix
  • Enhancement (new features, refinement)
  • Refactor
  • Add tests
  • Build / Development Environment
  • Documentation

SUMMARY

#8470 introduced a feature flag that is a function, for customizing the query cost estimate provided by different backend engines (currently supported only in Presto). The presence of a function in the feature flags breaks the JSON serialization of the payload, when sending it to the frontend.

I fixed it by using the pessimistic JSON encoder, which fallbacks to a string representation of the object when the serialization fails.

TEST PLAN

I hit the error when deploying a custom feature flag, not sure why it wasn't triggered in #8470. Fixed it and verified it now works.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Changes UI
  • Requires DB Migration.
  • Confirm DB Migration upgrade and downgrade tested.
  • Introduces new feature or API
  • Removes existing feature or API

REVIEWERS

@khtruong

@willbarrett
Copy link
Member

Would it be worth wrapping this in a test? I can imagine additional feature flags being introduced that could break the functionality further.

@betodealmeida
Copy link
Member Author

Would it be worth wrapping this in a test? I can imagine additional feature flags being introduced that could break the functionality further.

Good point, let me add a test.

@codecov-io
Copy link

codecov-io commented Nov 11, 2019

Codecov Report

Merging #8529 into master will increase coverage by 0.09%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #8529      +/-   ##
==========================================
+ Coverage   66.72%   66.81%   +0.09%     
==========================================
  Files         449      449              
  Lines       22696    22701       +5     
  Branches     2366     2366              
==========================================
+ Hits        15143    15167      +24     
+ Misses       7415     7396      -19     
  Partials      138      138
Impacted Files Coverage Δ
superset/views/core.py 72.1% <ø> (+0.14%) ⬆️
superset/views/database/views.py 92.23% <0%> (+0.07%) ⬆️
superset/utils/core.py 88.81% <0%> (+0.16%) ⬆️
superset/connectors/druid/views.py 69.33% <0%> (+0.2%) ⬆️
superset/views/base.py 72.54% <0%> (+1.9%) ⬆️
superset/utils/dict_import_export.py 55.26% <0%> (+34.21%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 49ea232...596a40d. Read the comment docs.

"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. :-)

@betodealmeida betodealmeida merged commit a58b392 into apache:master Nov 12, 2019
graceguo-supercat pushed a commit that referenced this pull request Nov 13, 2019
* Encode feature flags to JSON pessimistically

* Add unit test

* Remove old imports
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.36.0 First shipped in 0.36.0 labels Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/XS 🚢 0.36.0 First shipped in 0.36.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants