-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[Monitoring] Fix rison error #83987
[Monitoring] Fix rison error #83987
Conversation
Pinging @elastic/stack-monitoring (Team:Monitoring) |
@elasticmachine merge upstream |
💚 Build SucceededMetrics [docs]Async chunks
History
To update your PR or re-run it, just comment with: |
@@ -24,15 +24,16 @@ export function getSafeForExternalLink( | |||
|
|||
let newGlobalState = globalStateExecResult[1]; | |||
Object.keys(globalState).forEach((globalStateKey) => { | |||
let value = globalState[globalStateKey]; | |||
if (globalStateKey === 'cluster_uuid') { |
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.
Technically rison should already cast strings for us, I don't know why we even have to do this
But if we must, we should first check to see if it's already wrapped in quotes (or, you'll keep adding quotes to the value over and over again). So we should also add the following checks like this:
if (globalStateKey === 'cluster_uuid') { | |
if (globalStateKey === 'cluster_uuid' && value.charAt() !== '"' && value.charAt() !== '\'') { |
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.
Where are you seeing the double quotes happening? I'm trying to reproduce it locally but can't seem to find the right UI flow
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.
Here is an example: https://demo.elastic.co/app/monitoring#/home
- Notice how clicking on the first cluster has no quotes
...(cluster_uuid:C7AppFTyQfWdUL3ldutLjQ,
- And clicking on the second cluster has single quotes
...(cluster_uuid:'0f0rwRiWTjaJPTrORm4PoA',
Since, we don't take "checking first" into account we run the risk of adding unwanted quotes
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.
Oh, I'm a little confused sorry. Why are you testing this PR on the demo site? Are you connecting your local Kibana instance to that cluster or something?
Locally, with two clusters setup, I get from clicking on one cluster:
https://localhost:5601/app/monitoring#/overview?_g=(ccs:Monitoring,cluster_uuid:'1sO4J1fWQEq8AU628IoBGw',refreshInterval:(pause:!t,value:10000),time:(from:now-1h,to:now))
Then, I see https://localhost:5601/app/monitoring#/overview?_g=(refreshInterval:(pause:!t,value:10000),time:(from:now-1h,to:now),cluster_uuid:'TpRkL2e-QVaJisp084RwzQ') when clicking the other.
I can see in the code how we could be double quoting it, but I can't seem to find the use case of it actually happening (so I can verify the fix works)
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, I see it now "globalState" here is not actually the globalState we're use to, more of a way to override parameters (since we only use it in one place).
In which case, why not just pass the following cluster_uuid already as a quoted string here:
href={getSafeForExternalLink(`#/overview`, { cluster_uuid: cluster.cluster_uuid })} |
getSafeForExternalLink(`#/overview`, { cluster_uuid: `'${cluster.cluster_uuid}'` })
This way we don't have to check which key is which and how to cast it.
Might be more of nit/preference on my end, so I'm fine if you decide to keep it. Let me know and I'll approve it
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.
Fair enough. I worry that requiring the consumer to provide the '
will lead to us forgetting to do that. I'm not sure if there is a better way right now though.
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.
Looks good 👍
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Fixes #83212
This is a regression introduced by #78979 and the fix is to ensure the
cluster_uuid
is contained in quotes.