Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Remove positions from json_metadata #17766

Merged
merged 4 commits into from
Dec 15, 2021
Merged

fix: Remove positions from json_metadata #17766

merged 4 commits into from
Dec 15, 2021

Conversation

geido
Copy link
Member

@geido geido commented Dec 15, 2021

SUMMARY

This PR is a follow-up of PR #17570 in response to the issue that was brought in revert-PR #17753.
The changes in PR #17570 saved the positions in the json_metadata of a Dashboard even if that wasn't really necessary. It appears that very large dashboards might encounter an error as the positions might become too large AND/OR non-ascii characters might cause the json parsing to fail.

This PR forcefully removes the positions from the metadata, while making sure that all the related logics remain in place. It also introduces a temporary fix to make sure that Dashboards currently affected by this issue should ignore the positions in their metadata entirely.

TESTING INSTRUCTIONS

  1. Open a very large Dashboard
  2. Edit and Save the changes
  3. Make sure everything works as expected

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@geido
Copy link
Member Author

geido commented Dec 15, 2021

Confirmation that the issue is resolved will be very much appreciated. CC @serenajiang @etr2460 @graceguo-supercat

@@ -238,6 +238,8 @@ def set_dash_metadata( # pylint: disable=too-many-locals
if int(key) in slice_ids
}
md["default_filters"] = json.dumps(applicable_filters)
# positions have its own column, no need to store it in metadata
md.pop("positions", None)
Copy link
Member

@kgabryje kgabryje Dec 15, 2021

Choose a reason for hiding this comment

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

Maybe we should do a migration that removes positions from metadata instead of popping it in dao?

Copy link
Member Author

@geido geido Dec 15, 2021

Choose a reason for hiding this comment

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

positions still need to be passed to the set_dash_metadata function as certain logics are happening here that use it. What it does not need is to be stored as its own object in the metadata, that's why it's now being popped out from the metadata object.

In general, the set_dash_metadata function has some pretty mixed logic and it would require a bigger refactor. Things like the title, the css, and other data that is unrelated to the dashboard metadata is being used here when it shouldn't. Let's plan for a full refactor. CC @rusackas

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for clarification!


// temporary fix to remove positions from dashboards' metadata
if (metadata?.positions) {
delete metadata.positions;
Copy link
Member Author

@geido geido Dec 15, 2021

Choose a reason for hiding this comment

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

This is to ensure that dashboards that are being affected by an excessively large positions object can work properly. This check can be likely removed in the near future.

Copy link
Member

Choose a reason for hiding this comment

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

sorry, why would we be able to remove this in the future? or actually, why do we need this at all if we're removing the attribute in the backend below?

Copy link
Member Author

@geido geido Dec 15, 2021

Choose a reason for hiding this comment

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

@etr2460 all the dashboards that have been saved after the changes were introduced have the positions object appearing in their metadata inside the properties modal. I could not reproduce the error in the first place, so I wasn't sure whether that might also cause any problem. This just ensures it won't ever appear in the metadata to the user. I think it can be removed in the future assuming most dashboards will be then be updated and their positions object removed by the backend when saved.

Copy link
Member

Choose a reason for hiding this comment

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

i see, so this is an attempt to fix up the potentially broken json_metadata. makes sense, thanks!

Copy link
Member

@kgabryje kgabryje left a comment

Choose a reason for hiding this comment

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

Code looks good to me, tested and everything works as before (which is good). Let's wait for confirmation that it solves the issue since I couldn't reproduce it.

@etr2460
Copy link
Member

etr2460 commented Dec 15, 2021

/testenv up

@etr2460
Copy link
Member

etr2460 commented Dec 15, 2021

spinning up a testenv here to both try and repro the bug and to see if this resolves the issue we were seeing with doubling the position json in the database

@github-actions
Copy link
Contributor

@etr2460 Ephemeral environment spinning up at http://34.215.104.58:8080. Credentials are admin/admin. Please allow several minutes for bootstrapping and startup.

@serenajiang
Copy link
Contributor

Confirmed fix 🥳

Copy link
Member

@etr2460 etr2460 left a comment

Choose a reason for hiding this comment

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

Thanks for testing @serenajiang. let's ship it!

Copy link
Member

@rusackas rusackas left a comment

Choose a reason for hiding this comment

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

Code looks fine to me, and tested empirically - I wasn't able to break anything! 🥳

@rusackas rusackas merged commit 274fb37 into apache:master Dec 15, 2021
@github-actions
Copy link
Contributor

Ephemeral environment shutdown and build artifacts deleted.

eschutho pushed a commit that referenced this pull request Dec 21, 2021
* Remove positions from json_metadata

* Update superset-frontend/src/dashboard/components/PropertiesModal/index.tsx

Co-authored-by: Kamil Gabryjelski <kamil.gabryjelski@gmail.com>

* Indent

Co-authored-by: Kamil Gabryjelski <kamil.gabryjelski@gmail.com>
(cherry picked from commit 274fb37)
shcoderAlex pushed a commit to casual-precision/superset that referenced this pull request Feb 7, 2022
* Remove positions from json_metadata

* Update superset-frontend/src/dashboard/components/PropertiesModal/index.tsx

Co-authored-by: Kamil Gabryjelski <kamil.gabryjelski@gmail.com>

* Indent

Co-authored-by: Kamil Gabryjelski <kamil.gabryjelski@gmail.com>
bwang221 pushed a commit to casual-precision/superset that referenced this pull request Feb 10, 2022
* Remove positions from json_metadata

* Update superset-frontend/src/dashboard/components/PropertiesModal/index.tsx

Co-authored-by: Kamil Gabryjelski <kamil.gabryjelski@gmail.com>

* Indent

Co-authored-by: Kamil Gabryjelski <kamil.gabryjelski@gmail.com>
@mistercrunch mistercrunch added 🍒 1.4.0 🍒 1.4.1 🍒 1.4.2 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.5.0 labels Mar 13, 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/S v1.4 🍒 1.4.0 🍒 1.4.1 🍒 1.4.2 🚢 1.5.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants