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

Check class instance state is mutated #209

Open
andygout opened this issue Oct 18, 2022 · 0 comments
Open

Check class instance state is mutated #209

andygout opened this issue Oct 18, 2022 · 0 comments

Comments

@andygout
Copy link
Contributor

The categoryInCheckName function that appears in these lines and below mutates the state of the Check class instance (the check argument).

function categoryInCheckName(healthCheck, check){
	check.name = healthCheck.name + ': ' + check.name;
	return check;
}

If a check invokes the asArray() method more than once then the healthCheck.name value will keep getting prefixed to the start of the new check name, resulting in check names such as:

Backend key: Backend key: The shared backend key has been rotated recently

when the desired result is:

Backend key: The shared backend key has been rotated recently

There are legitimate reasons why asArray() may be called twice and cause this effect - this was happening in next-health and was fixed by this PR: https://github.com/Financial-Times/next-health/pull/360.

The preferred solution would be to fix this issue at source and allow asArray() to be invoked multiple times without affecting the state of the Check class instances property values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant