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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,15 @@ const PropertiesModal = ({

form.setFieldsValue(dashboardInfo);
setDashboardInfo(dashboardInfo);
setJsonMetadata(metadata ? jsonStringify(metadata) : '');
setOwners(owners);
setRoles(roles);
setColorScheme(metadata.color_scheme);

// 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!

}
setJsonMetadata(metadata ? jsonStringify(metadata) : '');
},
[form],
);
Expand Down
3 changes: 3 additions & 0 deletions superset/dashboards/dao.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,9 @@ def set_dash_metadata( # pylint: disable=too-many-locals
}
md["default_filters"] = json.dumps(applicable_filters)

# positions have its own column, no need to store it in metadata
md.pop("positions", None)

# The css and dashboard_title properties are not part of the metadata
# TODO (geido): remove by refactoring/deprecating save_dash endpoint
if data.get("css") is not None:
Expand Down