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: Make links and icons setting migration more resilient #39

Merged
merged 1 commit into from
Apr 26, 2024

Conversation

tgxworld
Copy link
Contributor

This commit updates the migrations to assume that the old setting value
may be invalid so that we don't end up with a new setting which fails
the objects schema validation.

This is a follow up to 7e304e0 which
added migrations for the links and icons settings. We have
gotten reports of errors happening with the migrations because the value of the old
setting before migration did not follow the "informal" format required
previously. Since there was nothing enforcing the format for the value
previously, we need to assume the worst possible cases in our
migrations.

@tgxworld tgxworld force-pushed the make_migration_more_resistant_to_invalid_formats branch from 0fb54ed to 51920ec Compare April 26, 2024 08:34
This commit updates the migrations to assume that the old setting value
may be invalid so that we don't end up with a new setting which fails
the objects schema validation.

This is a follow up to 7e304e0 which
added migrations for the `links` and `icons` settings. We have
gotten reports of errors happening with the migrations because the value of the old
setting before migration did not follow the "informal" format required
previously. Since there was nothing enforcing the format for the value
previously, we need to assume the worst possible cases in our
migrations.
@tgxworld tgxworld force-pushed the make_migration_more_resistant_to_invalid_formats branch from 51920ec to 4756128 Compare April 26, 2024 08:35
target
}
oldSetting.split("|").forEach((link) => {
let [text, url, target] = link.split(",").map((s) => s.trim());
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you expect text, url, target to mutate?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah ok, I see below that target might. All good.


settings.set("icons", newSetting);
settings.set("icons", newIcons);
Copy link
Contributor

Choose a reason for hiding this comment

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

Jut to check,

{
  icon_name: iconName,
  url: undefined,
  target: undefined,
}

is valid for settings? since the split(",") may land up with just one item in the array. (same for newLinks)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't get undefined anymore since this is what the PR is trying to solve now. target will always be set and we only add a link if icon_name and url is not undefined.

Copy link
Contributor

@nattsw nattsw left a comment

Choose a reason for hiding this comment

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

Going to approve since you mention it's urgent, but I would want to care about null/undefined values in the conversions.

@tgxworld tgxworld merged commit 5d9fd02 into main Apr 26, 2024
4 checks passed
@tgxworld tgxworld deleted the make_migration_more_resistant_to_invalid_formats branch April 26, 2024 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants