OpenChemistry / mongochemserver

Server code for MongoChem chemical data
BSD 3-Clause "New" or "Revised" License
15 stars 9 forks source link

Open Babel crashes the server for an invalid InChI #105

Closed psavery closed 5 years ago

psavery commented 5 years ago

If an invalid InChI gets passed to Open Babel, Open Babel throws a std::logic_error exception, which causes the girder server to terminate. The output from the girder server is as follows:

terminate called after throwing an instance of 'std::logic_error'
  what():  basic_string::_M_construct null not valid
Aborted (core dumped)
psavery commented 5 years ago

After a little bit of testing, I think that we need to validate just the first part of the InChI string. I think that as long as the first part is valid, then it won't crash, but return an error if it is invalid.

The first part being: InChI=<num><S or no S>/