-
Notifications
You must be signed in to change notification settings - Fork 274
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
Routing: fix mis-ordered conditional for orgAddress #1457
Conversation
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.
lgtm! perhaps we should add some test cases to cover the various conditions?
Polishes the routing behaviour: - Avoid double slashes (`//`) on home paths - Avoid parsing label data from query strings if a preferences path isn't found
Good call! I've added tests for all the exposed internal functions for getting and parsing paths. In the process, I found a few rough edges and smoothed them out: 36ea8c8. More importantly, I found the real cause of the bug that is causing all permissions changes at the moment to fail: 7bf1714. Let me know how this looks—can split out into separate PRs if we want to discuss / work on 36ea8c8 separately! |
src/routing.js
Outdated
} | ||
|
||
return getPath({ | ||
...locator, |
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.
The problem was that we weren't passing along the locator.mode.orgAddress
above, causing this to not produce the correct path in the signer panel.
Wasn't sure deep merging was the best approach vs. individually selecting the keys we expect, but felt like the most safe in case we add more keys to locator
in the future.
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.
Well found! I think this is fine for now.
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.
I’m wondering if that could be an issue, since it now always extends locator
. A change of mode (e.g. from org to onboarding) would copy the entries of the mode A into the mode B, and going the other way will copy entries (which might be undesired) from the mode B back into the mode A.
update()
used to have an extend
param to let people decide, but we ended up moving this on the consumer side to make it behave always the same: #1272 (comment)
The problem was that we weren't passing along the
locator.mode.orgAddress
above, causing this to not produce the correct path in the signer panel.
Do you know if the issue is related to mode
not being properly extended in an update()
call?
In any case, this is probably something that will keep happening, since we have these two nested objects. I think update()
should let consumers either set or extend the mode and the preferences, independently or together. We could express this in different ways, but perhaps adding some validation / errors could be enough (e.g. if orgAddress
is missing from an update)? Or should we provide a way to set / extend / reset any of the two components?
Edit: wondering if having an automatic inheritance of mode.orgAddress
, like we already have for mode.name
, would be enough?
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.
Right, as mentioned in #1457 (comment), it sounds like we should prefer to use the function variant of path()
when we want to extend an existing mode.
What do you think about staying as close to React.setState()
's behaviour as possible then—if you change an object, you overwrite that object entirely (to the point where we don't even inherit mode.name
)?
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.
What do you think about staying as close to
React.setState()
's behaviour as possible then—if you change an object, you overwrite that object entirely (to the point where we don't even inheritmode.name
)?
That sounds good yes. We could do this and also have errors?
- When
mode.name
is not set. - When
mode.orgAddress
is not set (org mode). - When
mode.instancePath
is set withoutmode.instanceId
(org mode). - When
mode.status
is not set (onboarding mode). - When
preferences.subsection
is set withoutpreferences.section
.
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.
To be clear, we would use log()
for the errors?
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.
I was thinking of throwing? To make sure we don’t forget anything when updating the mode.
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.
Closing an offline discussion, we decided to:
- Log a warning
- On production, send an error to sentry
- Move the sentry configuration to be environment variable-controlled
- Only initialize sentry on
*.aragon.org
domains (SENTRY_DOMAIN=*.aragon.org
)
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.
Logged warnings in c88176d; will add the sentry bits in another PR.
// Ignore labels if search does not contain a preferences path | ||
const labels = searchParams.has('preferences') |
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.
💯
src/routing.js
Outdated
} | ||
|
||
return getPath({ | ||
...locator, |
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.
I’m wondering if that could be an issue, since it now always extends locator
. A change of mode (e.g. from org to onboarding) would copy the entries of the mode A into the mode B, and going the other way will copy entries (which might be undesired) from the mode B back into the mode A.
update()
used to have an extend
param to let people decide, but we ended up moving this on the consumer side to make it behave always the same: #1272 (comment)
The problem was that we weren't passing along the
locator.mode.orgAddress
above, causing this to not produce the correct path in the signer panel.
Do you know if the issue is related to mode
not being properly extended in an update()
call?
In any case, this is probably something that will keep happening, since we have these two nested objects. I think update()
should let consumers either set or extend the mode and the preferences, independently or together. We could express this in different ways, but perhaps adding some validation / errors could be enough (e.g. if orgAddress
is missing from an update)? Or should we provide a way to set / extend / reset any of the two components?
Edit: wondering if having an automatic inheritance of mode.orgAddress
, like we already have for mode.name
, would be enough?
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.
💯 💯 💯
See https://sentry.io/share/issue/6f218cc4d1434b28b606e23b12b3f743/
Couldn't actually reproduce the error, but on inspection, it was clear the existence conditional (
if (!orgAddress)
) was placed too low.Ended up making a slightly larger change, because it felt more clear to nest everything related to the
'org'
mode in a code block.