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

[Monitoring] Fix rison error #83987

Merged
merged 2 commits into from
Nov 25, 2020

Conversation

chrisronline
Copy link
Contributor

Fixes #83212

This is a regression introduced by #78979 and the fix is to ensure the cluster_uuid is contained in quotes.

@elasticmachine
Copy link
Contributor

Pinging @elastic/stack-monitoring (Team:Monitoring)

@chrisronline chrisronline changed the title Put the cluster_uuid in quotes [Monitoring] Fix rison error Nov 20, 2020
@chrisronline
Copy link
Contributor Author

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
monitoring 952.1KB 952.2KB +58.0B

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@@ -24,15 +24,16 @@ export function getSafeForExternalLink(

let newGlobalState = globalStateExecResult[1];
Object.keys(globalState).forEach((globalStateKey) => {
let value = globalState[globalStateKey];
if (globalStateKey === 'cluster_uuid') {
Copy link
Contributor

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:

Suggested change
if (globalStateKey === 'cluster_uuid') {
if (globalStateKey === 'cluster_uuid' && value.charAt() !== '"' && value.charAt() !== '\'') {

Copy link
Contributor Author

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

Copy link
Contributor

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

Copy link
Contributor Author

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)

Copy link
Contributor

@igoristic igoristic Nov 24, 2020

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 })}
so it'd look something like:

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

Copy link
Contributor Author

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.

Copy link
Contributor

@igoristic igoristic left a comment

Choose a reason for hiding this comment

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

Looks good 👍

@chrisronline chrisronline merged commit 0f78022 into elastic:master Nov 25, 2020
@chrisronline chrisronline deleted the monitoring/rison_Fix branch November 25, 2020 13:50
chrisronline added a commit to chrisronline/kibana that referenced this pull request Nov 25, 2020
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
chrisronline added a commit to chrisronline/kibana that referenced this pull request Nov 25, 2020
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
chrisronline added a commit that referenced this pull request Nov 25, 2020
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
chrisronline added a commit that referenced this pull request Nov 25, 2020
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Stack Monitoring] After 7.10.0 Upgrade Receiving an Error Message when Loading Stack Monitoring
4 participants