Anvil Community Forum

Improve error message for Internal server error

I have some uplink code that sends data (a list of dicts) to the anvil server code. The data is passed to this code as the “value”:

def set_global(name, value):
  row = _get_global_row(name)
  row.update(data=value, updated=datetime.now())

Not very exciting, until you run the code and get this rather unhelpful error (at the row.update line):

Traceback (most recent call last):
  File "/Users/mjm/Dropbox/Devel/ACHN/Anvil_Binnenmelder/binnenmelder/src/binnenmelder/plandag_info_checker.py", line 128, in <module>
    plandag_poller()
  File "/Users/mjm/Dropbox/Devel/ACHN/Anvil_Binnenmelder/binnenmelder/src/binnenmelder/plandag_info_checker.py", line 90, in plandag_poller
    upload_plandag_info(df)
  File "/Users/mjm/Dropbox/Devel/ACHN/Anvil_Binnenmelder/binnenmelder/src/binnenmelder/plandag_info_checker.py", line 80, in upload_plandag_info
    anvil.server.call('upload_plandag_info', data)
  File "/Users/mjm/Dropbox/Devel/ACHN/Anvil_Binnenmelder/binnenmelder/.venv/lib/python3.9/site-packages/anvil/server.py", line 395, in call
    return _do_call(args, kwargs, fn_name=fn_name)
  File "/Users/mjm/Dropbox/Devel/ACHN/Anvil_Binnenmelder/binnenmelder/.venv/lib/python3.9/site-packages/anvil/server.py", line 387, in _do_call
    return _threaded_server.do_call(args, kwargs, fn_name=fn_name, live_object=live_object)
  File "/Users/mjm/Dropbox/Devel/ACHN/Anvil_Binnenmelder/binnenmelder/.venv/lib/python3.9/site-packages/anvil/_threaded_server.py", line 412, in do_call
    raise error_from_server
anvil._server.InternalError: Internal server error: 5114160c907b

After a lot of spelunking I found out that one of the values of some dicts contained an erroneous value of “nan” (as an expression, not a string), caused by an Pandas Dataframe.to_dict(‘records’). Obviously the Pandas NaN value was incorrectly exported. Easily fixed once you know it.

So I’m only posting this because of the “internal server error” in the hope that can be turnes into something more useful.

2 Likes

Hi @mjmare,

Thanks for raising this. Agreed, it should fail more gracefully - I’ve added this to our list.

3 Likes