The /record/latest endpoint calls the get_latest function with an argument n to return JSON metadata for the n latest records from the OpenSearch index. This function is only called from the HEPData code with n=3 for displaying information about the three latest records on the HEPData homepage via hepdata_home.js. Recently, I noticed Sentry exceptions from a RequestError with n=12000 arising from this line and a ValueError with n=-5 arising from this line. The get_latest function should check that the value of the argument n is an integer between 0 and 10000, otherwise it should return an error message in JSON format.
The
/record/latestendpoint calls theget_latestfunction with an argumentnto return JSON metadata for thenlatest records from the OpenSearch index. This function is only called from the HEPData code withn=3for displaying information about the three latest records on the HEPData homepage viahepdata_home.js. Recently, I noticed Sentry exceptions from aRequestErrorwithn=12000arising from this line and aValueErrorwithn=-5arising from this line. Theget_latestfunction should check that the value of the argumentnis an integer between 0 and 10000, otherwise it should return an error message in JSON format.