I noticed a slash at the end of your service url around line 62. I don't think it should be there, so try removing it along with my previous suggestion.
'service url': 'https://services6.arcgis.com/ ... /Complaint/FeatureServer/0/'
If that doesn't fix it , then I'd add a "print sql" around line 115, as indicated above, which should show you what the where query is.
# build sql
sql = "{} != '{}'".format(message['status field'], message['completed value'])
sql += " AND {}".format(message['query'])
print sql # find out if sql is being properly formated
feature_layer = FeatureLayer(email_service['service url'], target)
features = _get_features(feature_layer, sql)
From the code it looks like it should be:
EMAIL != 'Completed' AND STATUS = 'Unassigned'
Are the fields STATUS and EMAIL in the feature you are querying?
Also, does the error message indicate which line it is happening on? It looks like the JSON response from the query is being printed out.