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

mapper [x] cannot be changed from type [float] to [long] #386

Closed
0x0elliot opened this issue Oct 7, 2023 · 3 comments
Closed

mapper [x] cannot be changed from type [float] to [long] #386

0x0elliot opened this issue Oct 7, 2023 · 3 comments
Labels
bug Something isn't working untriaged

Comments

@0x0elliot
Copy link

0x0elliot commented Oct 7, 2023

The following covers what the bug is, instructions to reproduce it and why i think it happens.

  • We use opensearch where I work
  • One day, I got this error:
Screenshot 2023-10-08 at 4 32 06 AM - I am confident this is because of how the library deals with types internally to speak to opensearch API. the following is why: - This error comes specifically when workflow.actions.position.X has a value of **float64(206)**. Usually, since these positions are entered by the user through the GUI, the probability of these positional values being perfect is less. Usually, they have a decimal at the end. But when i got this bug, It just so happened that there was a perfect value at use. Screenshot 2023-10-08 at 4 37 09 AM
  • Here is how the struct for this object looks like:
Screenshot 2023-10-08 at 4 39 37 AM

Here is what i think is happening demonstrated with an example (this is pretty interesting):
image

  • this is for a golang code that uses a float value, puts it into a struct (which expects float64), converts it into JSON.

image
image

  • Notice how even for values which are typed as float64, the JSON object converted might convert them into what might be confused as an integer, rather than a float.
  • This might cause the API server to throw the errors it is throwing :)

Update:

Screenshot 2023-10-08 at 5 09 07 AM

this fixes the issue temporarily but i can see similar annoying bugs with timestamps as well. Thought you all should know.

@0x0elliot 0x0elliot added bug Something isn't working untriaged labels Oct 7, 2023
@0x0elliot 0x0elliot changed the title mapper [x] cannot be changed from type [float64] to [long] #357 mapper [x] cannot be changed from type [float] to [long] #357 Oct 7, 2023
@0x0elliot 0x0elliot changed the title mapper [x] cannot be changed from type [float] to [long] #357 mapper [x] cannot be changed from type [float] to [long] Oct 7, 2023
@0x0elliot
Copy link
Author

0x0elliot commented Oct 8, 2023

For context, we do use json.Marshal() ourselves to convert these values to JSON. so, technically, it's us who is causing this bug, but I wonder if you folks can also watch out for something like this somehow.

@dblock
Copy link
Member

dblock commented Oct 9, 2023

Thanks for the report @0x0elliot. What do you expect the library to do in this case? Maybe try to write a unite test that reproduces the error?

@0x0elliot
Copy link
Author

0x0elliot commented Oct 12, 2023

Thanks for the report @0x0elliot. What do you expect the library to do in this case? Maybe try to write a unite test that reproduces the error?

Thanks for the response @dblock. I decided that it's rather a encoding/json issue and has nothing to do with go-opensearch. But this existing in the first place would be important for anyone else coming across such bugs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working untriaged
Projects
None yet
Development

No branches or pull requests

2 participants