-
Notifications
You must be signed in to change notification settings - Fork 45
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
FIX: Make links
and icons
setting migration more resilient
#39
Conversation
0fb54ed
to
51920ec
Compare
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.
51920ec
to
4756128
Compare
target | ||
} | ||
oldSetting.split("|").forEach((link) => { | ||
let [text, url, target] = link.split(",").map((s) => s.trim()); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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
.
There was a problem hiding this 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.
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
andicons
settings. We havegotten 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.