AttributeError: 'SerializationError' object has no attribute 'message'

The following client side line :

data=anvil.server.call('run_service_stats',self.item['country'],self.item['sd'],self.item['ed'])

is giving this error :

AttributeError: 'SerializationError' object has no attribute 'message'

The server function performs some SQL and a print just before the return shows it is returning the data I expect which is an array of dicts :

[{‘country’: ‘Eritrea’, ‘calls’: Decimal(‘11’), ‘mins’: Decimal(‘1.72’), ‘ACD’: Decimal(‘0.16’)}, {‘country’: ‘Eritrea’, ‘calls’: Decimal(‘34’), ‘mins’: Decimal(‘1.72’), ‘ACD’: Decimal(‘0.05’)}]

Any pointers would be gratefully received as I don’t really understand the error.

(edit - anything to do with this? https://github.com/skulpt/skulpt/issues/464)

David, can you show us the code in run_service_stats()?

Sure (some data redacted). This is a stripped down version of the original function purely for debugging this issue.
It calls some other functions as well, but the important bit (I think) is that the print statement before the return shows the correct data.

@anvil.server.callable
def run_service_stats(country,start_date=None,end_date=None):
  db=DB("redacted")
  sql="""
    SELECT 
    	country, SUM(calls) as calls, round(SUM((billmsec/1000)/60),2) as mins,
    	round(SUM((billmsec/1000)/60) / sum(calls),2) as ACD
    FROM <redacted>
    where billmsec>0
    and country=%s
    and cast(stamp as date) between %s and %s
    group by country;  
  """
  params=(str(country),str(start_date),str(end_date))
  data = db.fetch_summary_stats(sql,params)
  print("HERE")
  print(data)
  return data

edit - might be relevant that I am using Python 3.6 in the server whilst the client is using 2.7-ish (according to the docs).

Well, nothing obvious sticks out to me. First, have you tried replacing the 2 occurrences of the triple quotes with single quotes in the assignment to the sql variable? Second, can you provide actual example values for start_date and end_date? Third, the 2 different versions of Python could be the issue - Ian/Meredydd? Fourth, perhaps it is a Skuplt problem.

This certainly looks like an Anvil bug to me! Moving to Bug Reports, and getting our thinking caps on…

Some more detail - I am calling this server function from a repeating panel’s line item form.

Reason that might be relevant is that a very similar function (returning the same type of data) is run from the parent and works fine. However, running a different function that also does a DB lookup doesn’t fail…almost certainly something I’m doing wrong, but the error doesn’t help me pin point it.

Do Decimals now works as a data type that can be sent through Anvil server calls? My (third party) database is full of them and being able to use them would be nice!

@troberts - no. That was indeed the problem I was having here.

Converted the “Decimal” fields to floats and all was well.

I couldn’t relate the error message to the problem.

@david.wylie Does this still happen? Did you work around in the end?

I’ve not had it for a while, and I converted the “decimal” return types to float. I’ve not had an issue since then, I don;t think.

Ah fine, then I think it’s most likely that decimal was the culprit. Closing for now, do open a new topic if it happens again.