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

Add an option for deleting fields that contain empty string values in jsonData #56

Closed
wants to merge 2 commits into from

Conversation

katebrenner
Copy link
Contributor

When jsonData.endpoint is an empty string, we were experiencing bugs outlined in this Twinmaker issue. The bug could also be fixed in Twinmaker itself but I wonder if there are other places in which having an empty string endpoint would cause unexpected behaviors.

To reproduce, follow the steps here and you should no longer see the error.

@katebrenner katebrenner requested a review from a team as a code owner August 8, 2023 20:37
@katebrenner katebrenner requested review from idastambuk and kevinwcyu and removed request for a team August 8, 2023 20:37
@CLAassistant
Copy link

CLAassistant commented Aug 8, 2023

CLA assistant check
All committers have signed the CLA.

@idastambuk
Copy link
Contributor

I see some places in Twinmaker that we check for the endpoint string, but can you point me to the piece code this bug is caused by? I wonder if we're just not checking for truthy values properly there, since I would normally expect if something is an empty string, that it doesn't get evaluated at all.

@katebrenner
Copy link
Contributor Author

I see some places in Twinmaker that we check for the endpoint string, but can you point me to the piece code this bug is caused by? I wonder if we're just not checking for truthy values properly there, since I would normally expect if something is an empty string, that it doesn't get evaluated at all.

It actual looks like the error is somewhere deep in a dependency of the scene viewer panel, where new URL('') is being called and resulting in Uncaught TypeError: Failed to construct 'URL': Invalid URL.

To clarify, when I mentioned that we could fix this in Twinmaker itself, I was thinking more along the lines of adding a useEffect in ConfigEditor.tsx to check if the value was an empty string, but didn't actually see a place in which we're not checking truthy values in the Twinmaker code, but that's a good point, maybe this can be fixed in SceneViewer.tsx, I'll take a look :). Regardless, I do wish we weren't passing along empty strings as values in the jsonData when the field is empty

@idastambuk
Copy link
Contributor

I see some places in Twinmaker that we check for the endpoint string, but can you point me to the piece code this bug is caused by? I wonder if we're just not checking for truthy values properly there, since I would normally expect if something is an empty string, that it doesn't get evaluated at all.

It actual looks like the error is somewhere deep in a dependency of the scene viewer panel, where new URL('') is being called and resulting in Uncaught TypeError: Failed to construct 'URL': Invalid URL.

To clarify, when I mentioned that we could fix this in Twinmaker itself, I was thinking more along the lines of adding a useEffect in ConfigEditor.tsx to check if the value was an empty string, but didn't actually see a place in which we're not checking truthy values in the Twinmaker code, but that's a good point, maybe this can be fixed in SceneViewer.tsx, I'll take a look :). Regardless, I do wish we weren't passing along empty strings as values in the jsonData when the field is empty

I see your point in not passing empty strings if something isn't actually defined. But I also feel like doing it isn't non-standard practice, at least as far as I've seen?🤔
Also, it would make sense to me that wherever something that might not be defined is used, like the endpoint, to have a condition for falsy anyway?
Meaning, I'd rather see it fixed in SceneViewer if it's not too complicated, but I'm ok with this solution!

@katebrenner
Copy link
Contributor Author

will likely close this pr in favor of grafana/grafana-iot-twinmaker-app#208

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

Successfully merging this pull request may close these issues.

None yet

3 participants