aleph-im/pyaleph

API crashes when requesting float values for startDate and endDate

Closed this issue · 0 comments

hoh commented

Problem

Calling the failing URL:
http://api1.aleph.im:4024/api/v0/messages.json?pagination=200&page=1&msgType=PROGRAM&startDate=1660828440.0&endDate=1660828500.0

Returns the error message: invalid literal for int() with base 10: '1660828440.0'

This URL works (no message but no error message):
http://api1.aleph.im:4024/api/v0/messages.json?pagination=200&page=1&msgType=PROGRAM&startDate=1660828440&endDate=1660828500

Diagnostic

Calling int() on a float is not supported by Python. Ex: int(0.5).

Relevant code:

start_date = int(request.query.get("startDate", 0))
end_date = int(request.query.get("endDate", 0))

Proposal

Replace int() with float().

Floating datetimes may be required for some usecases, so this should be fixed server side and not client side.