issues: 747702144
This data as json
id | node_id | number | title | user | state | locked | assignee | milestone | comments | created_at | updated_at | closed_at | author_association | pull_request | body | repo | type | active_lock_reason | performed_via_github_app | reactions | draft | state_reason |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
747702144 | MDU6SXNzdWU3NDc3MDIxNDQ= | 1100 | Error on OPTIONS request to database | 1319404 | closed | 0 | 2 | 2020-11-20T18:16:43Z | 2020-12-03T00:57:35Z | 2020-12-03T00:50:17Z | NONE | When I perform an OPTIONS request against a database or table datasette fails with an internal error. All these tests result in the traceback below. ``` curl -XOPTIONS http://127.0.0.1:8001/test-db curl -XOPTIONS http://127.0.0.1:8001/test-db/table1 curl -XOPTIONS http://127.0.0.1:8001/test-db/table1\?_search\=test ``` ``` Traceback (most recent call last): File "[path-to-python]/site-packages/datasette/app.py", line 1033, in route_path response = await view(request, send) File "[path-to-python]/site-packages/datasette/views/base.py", line 146, in view request, **request.scope["url_route"]["kwargs"] File "[path-to-python]/site-packages/datasette/views/base.py", line 118, in dispatch_request return await handler(request, *args, **kwargs) TypeError: object Response can't be used in 'await' expression ``` Making the `options` function in the `DataView` class async fixed it for me. ```python async def options(self, request, *args, **kwargs): r = Response.text("ok") if self.ds.cors: r.headers["Access-Control-Allow-Origin"] = "*" return r ``` | 107914493 | issue | {"url": "https://api.github.com/repos/simonw/datasette/issues/1100/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0} | completed |