fastsurvey / backend

FastSurvey's backend that's crunching the data
1 stars 0 forks source link

Statuscode 500 when updating a survey config #49

Closed dostuffthatmatters closed 3 years ago

dostuffthatmatters commented 3 years ago

I executed POST /users/123/surveys/badum successfully with a 200 response. The created config:

{
    "survey_name": "badum",
    "title": "Text Test",
    "description": "",
    "start": 1000000000,
    "end": 2000000000,
    "draft": false,
    "authentication": "open",
    "limit": 0,
    "fields": [
        {
            "type": "text",
            "title": "Why do you like ice cream?",
            "description": "",
            "min_chars": 10,
            "max_chars": 1000
        }
    ]
}

Then I tried to run PUT /users/123/surveys/badum and got a 500 in response. The new config passed with the request (only the timestamps have changed):

{
    "survey_name": "badum",
    "title": "Email Test",
    "description": "",
    "start": 1621712880,
    "end": 1653248880,
    "draft": false,
    "authentication": "open",
    "limit": 0,
    "fields": [
        {
            "type": "email",
            "title": "What is your email address?",
            "description": "",
            "regex": ".*",
            "hint": "Your email address ..."
        }
    ]
}

The server logs say:

INFO:     127.0.0.1:64196 - "PUT /users/123/surveys/badum HTTP/1.1" 500 Internal Server Error
ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "/Users/dostuffthatmatters/Documents/projects/current/fastsurvey/backend/venv/lib/python3.8/site-packages/uvicorn/protocols/http/httptools_impl.py", line 390, in run_asgi
    result = await app(self.scope, self.receive, self.send)
  File "/Users/dostuffthatmatters/Documents/projects/current/fastsurvey/backend/venv/lib/python3.8/site-packages/uvicorn/middleware/proxy_headers.py", line 45, in __call__
    return await self.app(scope, receive, send)
  File "/Users/dostuffthatmatters/Documents/projects/current/fastsurvey/backend/venv/lib/python3.8/site-packages/fastapi/applications.py", line 179, in __call__
    await super().__call__(scope, receive, send)
  File "/Users/dostuffthatmatters/Documents/projects/current/fastsurvey/backend/venv/lib/python3.8/site-packages/starlette/applications.py", line 111, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/Users/dostuffthatmatters/Documents/projects/current/fastsurvey/backend/venv/lib/python3.8/site-packages/starlette/middleware/errors.py", line 181, in __call__
    raise exc from None
  File "/Users/dostuffthatmatters/Documents/projects/current/fastsurvey/backend/venv/lib/python3.8/site-packages/starlette/middleware/errors.py", line 159, in __call__
    await self.app(scope, receive, _send)
  File "/Users/dostuffthatmatters/Documents/projects/current/fastsurvey/backend/venv/lib/python3.8/site-packages/starlette/middleware/cors.py", line 78, in __call__
    await self.app(scope, receive, send)
  File "/Users/dostuffthatmatters/Documents/projects/current/fastsurvey/backend/venv/lib/python3.8/site-packages/starlette/exceptions.py", line 82, in __call__
    raise exc from None
  File "/Users/dostuffthatmatters/Documents/projects/current/fastsurvey/backend/venv/lib/python3.8/site-packages/starlette/exceptions.py", line 71, in __call__
    await self.app(scope, receive, sender)
  File "/Users/dostuffthatmatters/Documents/projects/current/fastsurvey/backend/venv/lib/python3.8/site-packages/starlette/routing.py", line 566, in __call__
    await route.handle(scope, receive, send)
  File "/Users/dostuffthatmatters/Documents/projects/current/fastsurvey/backend/venv/lib/python3.8/site-packages/starlette/routing.py", line 227, in handle
    await self.app(scope, receive, send)
  File "/Users/dostuffthatmatters/Documents/projects/current/fastsurvey/backend/venv/lib/python3.8/site-packages/starlette/routing.py", line 41, in app
    response = await func(request)
  File "/Users/dostuffthatmatters/Documents/projects/current/fastsurvey/backend/venv/lib/python3.8/site-packages/fastapi/routing.py", line 182, in app
    raw_response = await run_endpoint_function(
  File "/Users/dostuffthatmatters/Documents/projects/current/fastsurvey/backend/venv/lib/python3.8/site-packages/fastapi/routing.py", line 133, in run_endpoint_function
    return await dependant.call(**values)
  File "./app/main.py", line 188, in update_survey
    await survey_manager.update(
  File "./app/survey.py", line 79, in update
    await self._update(username, survey_name, configuration)
  File "./app/survey.py", line 151, in _update
    assert '_id' in configuration.keys()
AssertionError

I am working on 0466523 (HEAD -> master, origin/master, origin/HEAD) Set access token expiry to one week.

dostuffthatmatters commented 3 years ago

However the survey config did update! When fetching all configs again the timestamps had been updated.