open-reaction-database / ord-interface

Search/browse interface and APIs for the Open Reaction Database
https://open-reaction-database.org
Apache License 2.0
19 stars 9 forks source link

Insufficient warnings when non-numeric float_value entered for data #48

Open connorcoley opened 3 years ago

connorcoley commented 3 years ago

When the data field is set to a string, e.g., "asdf", and numeric Data is selected using the radio buttons, the message will not be loaded properly and the error is that data requires one of {value, bytes_value, url}. It would be better to describe that the input was non-numeric but a numeric field was entered, however, this must occur on the JS side not in Python validations

miori-nd commented 4 months ago

Hi @connorcoley , could you describe how you replicated this issue in the interface? Was this encountered while searching, or elsewhere in the application?

connorcoley commented 4 months ago

This was in the graphical editor when contributing data. It's a rather weird edge case.

  1. Starting from a completely empty new reaction, add a component to input 1 and add a feature of type text with data/value "text_data". Saving this reaction and reloading the page shows that the message was saved properly.

  2. Starting from a completely empty new reaction, add a component to input 1 and add a feature of type number with data/value "5". Saving this reaction and reloading the page shows that the message was saved properly.

  3. Starting from a completely empty new reaction, add a component to input 1 and add a feature of type number with data/value "text_data". Saving this reaction and reloading the page shows that the message was not saved properly, and it will revert to a completely empty message (because no other fields are defined; if other fields were defined, only this 'feature' would be removed)

It's been a while, but IIRC the issue for this silent failure is that the attempted parsing of the data field to a number happens in JS and isn't passed through to Python during validations