This is the message that you get while hitting the /read endpoint for {"registration_status": "coming"}:
{
"errorMessage": "'str' object has no attribute 'isoformat'",
"stackTrace": [
" File \"/var/task/src/schemas.py\", line 17, in wrapt\n return util.add_cors_headers(fn(event, context, extras))\n",
" File \"/var/task/src/schemas.py\", line 53, in wrapt\n return fn(event, context, user, args)\n",
" File \"/var/task/src/schemas.py\", line 67, in wrapt\n return on_failure(event, context, user, args)\n",
" File \"/var/task/src/read.py\", line 103, in \n @ensure_role([['director']], on_failure=lambda e, c, u, a: organizer_read(e, c, u))\n",
" File \"/var/task/src/schemas.py\", line 66, in wrapt\n return fn(event, context, user, *args)\n",
" File \"/var/task/src/read.py\", line 90, in organizer_read\n return {\"statusCode\": 200, \"body\": stringify_timestamps(tidy_results(list(user_coll.find(event['query']))))}\n",
" File \"/var/task/src/read.py\", line 22, in stringify_timestamps\n obj[\"day_of\"][\"timestamps\"].get(event)[i] = obj[\"day_of\"][\"timestamps\"].get(event)[i] .isoformat()\n"
]
}
To solve this, add a safeguard if condition that only convert timestamps to string if they are currently not string
This is the message that you get while hitting the /read endpoint for {"registration_status": "coming"}: { "errorMessage": "'str' object has no attribute 'isoformat'", "stackTrace": [ " File \"/var/task/src/schemas.py\", line 17, in wrapt\n return util.add_cors_headers(fn(event, context, extras))\n", " File \"/var/task/src/schemas.py\", line 53, in wrapt\n return fn(event, context, user, args)\n", " File \"/var/task/src/schemas.py\", line 67, in wrapt\n return on_failure(event, context, user, args)\n", " File \"/var/task/src/read.py\", line 103, in\n @ensure_role([['director']], on_failure=lambda e, c, u, a: organizer_read(e, c, u))\n",
" File \"/var/task/src/schemas.py\", line 66, in wrapt\n return fn(event, context, user, *args)\n",
" File \"/var/task/src/read.py\", line 90, in organizer_read\n return {\"statusCode\": 200, \"body\": stringify_timestamps(tidy_results(list(user_coll.find(event['query']))))}\n",
" File \"/var/task/src/read.py\", line 22, in stringify_timestamps\n obj[\"day_of\"][\"timestamps\"].get(event)[i] = obj[\"day_of\"][\"timestamps\"].get(event)[i] .isoformat()\n"
]
}
To solve this, add a safeguard if condition that only convert timestamps to string if they are currently not string