{"html_url": "https://github.com/simonw/datasette/issues/1001#issuecomment-705904566", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1001", "id": 705904566, "node_id": "MDEyOklzc3VlQ29tbWVudDcwNTkwNDU2Ng==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-10-09T00:58:08Z", "updated_at": "2020-10-09T00:58:08Z", "author_association": "OWNER", "body": "To get a traceback:\r\n```\r\ndatasette . -p 8009 --pdb\r\n```\r\nAnd then:\r\n```\r\ncurl -XOPTIONS http://127.0.0.1:8009\r\n```\r\nThis causes the server to open a debugging prompt:\r\n```\r\nINFO: 127.0.0.1:59514 - \"OPTIONS / HTTP/1.1\" 500 Internal Server Error\r\n> /Users/simon/Dropbox/Development/datasette/datasette/views/base.py(115)dispatch_request()\r\n-> return await handler(request, *args, **kwargs)\r\n(Pdb) list\r\n110 \t def database_color(self, database):\r\n111 \t return \"ff0000\"\r\n112 \t\r\n113 \t async def dispatch_request(self, request, *args, **kwargs):\r\n114 \t handler = getattr(self, request.method.lower(), None)\r\n115 ->\t return await handler(request, *args, **kwargs)\r\n116 \t\r\n117 \t async def render(self, templates, request, context=None):\r\n118 \t context = context or {}\r\n119 \t template = self.ds.jinja_env.select_template(templates)\r\n120 \t template_context = {\r\n(Pdb) \r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 717768441, "label": "OPTIONS requests return a 500 error"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1001#issuecomment-705904679", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1001", "id": 705904679, "node_id": "MDEyOklzc3VlQ29tbWVudDcwNTkwNDY3OQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-10-09T00:58:32Z", "updated_at": "2020-10-09T00:58:32Z", "author_association": "OWNER", "body": "So the bug is in this code here: https://github.com/simonw/datasette/blob/703439bdc37e724b01bc6d7a1fc1d955795132f2/datasette/views/base.py#L113-L115", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 717768441, "label": "OPTIONS requests return a 500 error"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1001#issuecomment-705904759", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1001", "id": 705904759, "node_id": "MDEyOklzc3VlQ29tbWVudDcwNTkwNDc1OQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-10-09T00:58:47Z", "updated_at": "2020-10-09T00:58:47Z", "author_association": "OWNER", "body": "What should an OPTIONS request return, anyway?", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 717768441, "label": "OPTIONS requests return a 500 error"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1001#issuecomment-705904917", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1001", "id": 705904917, "node_id": "MDEyOklzc3VlQ29tbWVudDcwNTkwNDkxNw==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-10-09T00:59:25Z", "updated_at": "2020-10-09T00:59:25Z", "author_association": "OWNER", "body": "```\r\n~ % curl -XOPTIONS https://www.google.com/\r\n\r\n\r\n \r\n \r\n Error 405 (Method Not Allowed)!!1\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 717768441, "label": "OPTIONS requests return a 500 error"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1001#issuecomment-705905121", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1001", "id": 705905121, "node_id": "MDEyOklzc3VlQ29tbWVudDcwNTkwNTEyMQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-10-09T01:00:07Z", "updated_at": "2020-10-09T01:00:07Z", "author_association": "OWNER", "body": "The www.djangoproject.com site returns an empty page:\r\n```\r\n~ % curl -vv -XOPTIONS https://www.djangoproject.com/\r\n* Trying 151.101.42.217:443...\r\n* Connected to www.djangoproject.com (151.101.42.217) port 443 (#0)\r\n* ALPN, offering http/1.1\r\n* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256\r\n* Server certificate: osff2.map.fastly.net\r\n* Server certificate: GlobalSign CloudSSL CA - SHA256 - G3\r\n* Server certificate: GlobalSign Root CA\r\n> OPTIONS / HTTP/1.1\r\n> Host: www.djangoproject.com\r\n> User-Agent: curl/7.70.0\r\n> Accept: */*\r\n> \r\n* Mark bundle as not supporting multiuse\r\n< HTTP/1.1 200 OK\r\n< Connection: keep-alive\r\n< Content-Length: 0\r\n< Server: nginx\r\n< Content-Type: text/html; charset=utf-8\r\n< Allow: GET, HEAD, OPTIONS\r\n< Content-Language: en\r\n< X-Frame-Options: SAMEORIGIN\r\n< X-Content-Type-Options: nosniff\r\n< X-XSS-Protection: 1; mode=block\r\n< Strict-Transport-Security: max-age=31536000; includeSubDomains; preload\r\n< Access-Control-Allow-Origin: https://code.djangoproject.com\r\n< Accept-Ranges: bytes\r\n< Date: Fri, 09 Oct 2020 00:59:42 GMT\r\n< Via: 1.1 varnish\r\n< X-Served-By: cache-sjc10047-SJC\r\n< X-Cache: MISS\r\n< X-Cache-Hits: 0\r\n< X-Timer: S1602205182.833493,VS0,VE305\r\n< Vary: Accept-Language, Accept-Encoding\r\n< \r\n* Connection #0 to host www.djangoproject.com left intact\r\n~ % \r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 717768441, "label": "OPTIONS requests return a 500 error"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1001#issuecomment-705905418", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1001", "id": 705905418, "node_id": "MDEyOklzc3VlQ29tbWVudDcwNTkwNTQxOA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-10-09T01:00:54Z", "updated_at": "2020-10-09T01:00:54Z", "author_association": "OWNER", "body": "https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/OPTIONS", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 717768441, "label": "OPTIONS requests return a 500 error"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1001#issuecomment-705916614", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1001", "id": 705916614, "node_id": "MDEyOklzc3VlQ29tbWVudDcwNTkxNjYxNA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-10-09T01:37:06Z", "updated_at": "2020-10-09T01:37:06Z", "author_association": "OWNER", "body": "I'm tempted to imitate Django Rest Framework here: https://github.com/encode/django-rest-framework/blob/2e721cdbc85a924d0b0f093b86fe1497b58fe287/rest_framework/views.py#L514-L521\r\n```python\r\n def options(self, request, *args, **kwargs):\r\n \"\"\"\r\n Handler method for HTTP 'OPTIONS' request.\r\n \"\"\"\r\n if self.metadata_class is None:\r\n return self.http_method_not_allowed(request, *args, **kwargs)\r\n data = self.metadata_class().determine_metadata(request, self)\r\n return Response(data, status=status.HTTP_200_OK)\r\n```\r\nThat `determine_metadata()` default method does this: https://github.com/encode/django-rest-framework/blob/335054a5d36b352a58286b303b608b6bf48152f8/rest_framework/metadata.py#L29\r\n\r\nNote the comment at the top:\r\n```\r\n There are not any formalized standards for `OPTIONS` responses\r\n for us to base this on.\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 717768441, "label": "OPTIONS requests return a 500 error"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1001#issuecomment-705917015", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1001", "id": 705917015, "node_id": "MDEyOklzc3VlQ29tbWVudDcwNTkxNzAxNQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-10-09T01:38:49Z", "updated_at": "2020-10-09T01:38:49Z", "author_association": "OWNER", "body": "I actually have a sensible `OPTIONS` implementation here:\r\n\r\nhttps://github.com/simonw/datasette/blob/a648bb82bac201c7658f6fdb499ff8ac17ebd2e8/datasette/views/base.py#L154-L165\r\n\r\nI'm going to set the default one to return a 405 (Method Not Allowed) like Google does.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 717768441, "label": "OPTIONS requests return a 500 error"}, "performed_via_github_app": null}