home / github

Menu
  • Search all tables
  • GraphQL API

issue_comments

Table actions
  • GraphQL API for issue_comments

27 rows where "created_at" is on date 2022-11-30 and "updated_at" is on date 2022-11-30 sorted by updated_at descending

✎ View and edit SQL

This data as json, CSV (advanced)

Suggested facets: created_at (date)

issue 8

  • Make sure CORS works for write APIs 13
  • Interactive demo of Datasette 1.0 write APIs 4
  • latest.datasette.io Cloud Run deploys failing 3
  • Scripted exports 2
  • Don't allow writable API to edit the `_memory` database 2
  • GET requests against POST endpoints should not 500 error 1
  • API explorer should list mutable databases first 1
  • Intermittent `test_delete_row` test failure 1

user 2

  • simonw 26
  • eyeseast 1

author_association 2

  • OWNER 26
  • CONTRIBUTOR 1
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions issue performed_via_github_app
1332903011 https://github.com/simonw/datasette/issues/1922#issuecomment-1332903011 https://api.github.com/repos/simonw/datasette/issues/1922 IC_kwDOBm6k_c5Pcnxj simonw 9599 2022-11-30T23:45:29Z 2022-11-30T23:45:29Z OWNER

That worked for the preflight request - got this now:

So it looks like error responses (in this case for permission denied) are missing CORS headers.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Make sure CORS works for write APIs 1469973742  
1332855687 https://github.com/simonw/datasette/issues/1922#issuecomment-1332855687 https://api.github.com/repos/simonw/datasette/issues/1922 IC_kwDOBm6k_c5PccOH simonw 9599 2022-11-30T23:09:31Z 2022-11-30T23:09:31Z OWNER

Still getting a CORS header.

I tried it in Chrome, which outputs helpful messages to the console:

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Make sure CORS works for write APIs 1469973742  
1332851215 https://github.com/simonw/datasette/issues/1923#issuecomment-1332851215 https://api.github.com/repos/simonw/datasette/issues/1923 IC_kwDOBm6k_c5PcbIP simonw 9599 2022-11-30T23:04:56Z 2022-11-30T23:04:56Z OWNER

That fixed it.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
latest.datasette.io Cloud Run deploys failing 1470320227  
1332842435 https://github.com/simonw/datasette/issues/1923#issuecomment-1332842435 https://api.github.com/repos/simonw/datasette/issues/1923 IC_kwDOBm6k_c5PcY_D simonw 9599 2022-11-30T22:58:33Z 2022-11-30T22:58:33Z OWNER

https://stackoverflow.com/questions/74490465/github-actions-failing-for-setup-gcloud/74562740#74562740 suggests trying Python 3.9.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
latest.datasette.io Cloud Run deploys failing 1470320227  
1332835664 https://github.com/simonw/datasette/issues/1923#issuecomment-1332835664 https://api.github.com/repos/simonw/datasette/issues/1923 IC_kwDOBm6k_c5PcXVQ simonw 9599 2022-11-30T22:50:10Z 2022-11-30T22:51:25Z OWNER

https://stackoverflow.com/questions/74490465/github-actions-failing-for-setup-gcloud/74562526#74562526 suggests setting version: '318.0.0' of google-github-actions/setup-gcloud.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
latest.datasette.io Cloud Run deploys failing 1470320227  
1332698636 https://github.com/simonw/datasette/issues/1922#issuecomment-1332698636 https://api.github.com/repos/simonw/datasette/issues/1922 IC_kwDOBm6k_c5Pb14M simonw 9599 2022-11-30T20:25:50Z 2022-11-30T20:25:50Z OWNER

I just shipped this:

Access-Control-Allow-Methods: GET, POST, HEAD, OPTIONS

I'll try this out on latest.datasette.io - but I need to research more to check if this is a safe thing to do or not.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Make sure CORS works for write APIs 1469973742  
1332689547 https://github.com/simonw/datasette/issues/1922#issuecomment-1332689547 https://api.github.com/repos/simonw/datasette/issues/1922 IC_kwDOBm6k_c5PbzqL simonw 9599 2022-11-30T20:16:21Z 2022-11-30T20:16:46Z OWNER

That notebook: javascript viewof token = Inputs.text({ label: "Your API token" }) javascript viewof createResponse = Inputs.button("Create table", { value: null, reduce: async () => { const response = await fetch( "https://latest.datasette.io/ephemeral/-/create", { method: "POST", mode: "cors", headers: { Authorization: `Bearer {$token}`, "Content-Type": "application/json" }, body: JSON.stringify({ table: "my_new_table", row: { task: "Demonstrate a JSON creation from another domain" } }) } ); return await response.json(); } }) Based on this tip: https://talk.observablehq.com/t/best-pattern-for-click-here-to-submit-your-results-to-an-api-backend/7353/3

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Make sure CORS works for write APIs 1469973742  
1332688245 https://github.com/simonw/datasette/issues/1922#issuecomment-1332688245 https://api.github.com/repos/simonw/datasette/issues/1922 IC_kwDOBm6k_c5PbzV1 simonw 9599 2022-11-30T20:15:08Z 2022-11-30T20:15:08Z OWNER

Still getting a CORS error:

My hunch is this is because I'm not sending Access-Control-Allow-Methods: GET,HEAD,POST.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Make sure CORS works for write APIs 1469973742  
1332585861 https://github.com/simonw/datasette/issues/1922#issuecomment-1332585861 https://api.github.com/repos/simonw/datasette/issues/1922 IC_kwDOBm6k_c5PbaWF simonw 9599 2022-11-30T18:43:46Z 2022-11-30T18:43:46Z OWNER

Here's what Django Rest Framework does: https://github.com/encode/django-rest-framework/blob/1ae812ea209392ad76cc5d2f35f9f7fb337f63e4/rest_framework/views.py#L514-L521

python def options(self, request, *args, **kwargs): """ Handler method for HTTP 'OPTIONS' request. """ if self.metadata_class is None: return self.http_method_not_allowed(request, *args, **kwargs) data = self.metadata_class().determine_metadata(request, self) return Response(data, status=status.HTTP_200_OK) That default determine_metadata method looks like this: https://github.com/encode/django-rest-framework/blob/1ae812ea209392ad76cc5d2f35f9f7fb337f63e4/rest_framework/metadata.py#L61-L71

python def determine_metadata(self, request, view): metadata = OrderedDict() metadata['name'] = view.get_view_name() metadata['description'] = view.get_view_description() metadata['renders'] = [renderer.media_type for renderer in view.renderer_classes] metadata['parses'] = [parser.media_type for parser in view.parser_classes] if hasattr(view, 'get_serializer'): actions = self.determine_actions(request, view) if actions: metadata['actions'] = actions return metadata

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Make sure CORS works for write APIs 1469973742  
1332580395 https://github.com/simonw/datasette/issues/1922#issuecomment-1332580395 https://api.github.com/repos/simonw/datasette/issues/1922 IC_kwDOBm6k_c5PbZAr simonw 9599 2022-11-30T18:38:22Z 2022-11-30T18:38:22Z OWNER

@simon IMO, it should always be a 2XX series response, typically with no content & an extra Allow header with a list of HTTP verbs it responds to.

https://mastodon.social/@daniellindsley/109434186252099323

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Make sure CORS works for write APIs 1469973742  
1332572453 https://github.com/simonw/datasette/issues/1922#issuecomment-1332572453 https://api.github.com/repos/simonw/datasette/issues/1922 IC_kwDOBm6k_c5PbXEl simonw 9599 2022-11-30T18:30:38Z 2022-11-30T18:30:54Z OWNER

Started a conversation about how OPTIONS should work on Mastodon: https://fedi.simonwillison.net/@simon/109434148676475291

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Make sure CORS works for write APIs 1469973742  
1332561813 https://github.com/simonw/datasette/issues/1922#issuecomment-1332561813 https://api.github.com/repos/simonw/datasette/issues/1922 IC_kwDOBm6k_c5PbUeV simonw 9599 2022-11-30T18:20:05Z 2022-11-30T18:20:05Z OWNER

Weird, GitHub reply with a 404! ~ % curl -X OPTIONS https://github.com/ -i HTTP/2 404 server: GitHub.com date: Wed, 30 Nov 2022 18:19:39 GMT content-type: text/html; charset=utf-8 content-length: 0 strict-transport-security: max-age=31536000; includeSubdomains; preload x-frame-options: deny x-content-type-options: nosniff x-xss-protection: 0 referrer-policy: origin-when-cross-origin, strict-origin-when-cross-origin content-security-policy: default-src 'none'; base-uri 'self'; block-all-mixed-content; child-src github.com/assets-cdn/worker/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com objects-origin.githubusercontent.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com cdn.optimizely.com logx.optimizely.com/v1/events; font-src github.githubassets.com; form-action 'self' github.com gist.github.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com objects-origin.githubusercontent.com secured-user-images.githubusercontent.com/ opengraph.githubassets.com github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; worker-src github.com/assets-cdn/worker/ gist.github.com/assets-cdn/worker/ vary: Accept-Encoding, Accept, X-Requested-With x-github-request-id: DD6B:5ACA:102E8A6:1164A99:63879EBB

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Make sure CORS works for write APIs 1469973742  
1332561059 https://github.com/simonw/datasette/issues/1922#issuecomment-1332561059 https://api.github.com/repos/simonw/datasette/issues/1922 IC_kwDOBm6k_c5PbUSj simonw 9599 2022-11-30T18:19:20Z 2022-11-30T18:19:20Z OWNER

Two test failures: ``` ____ test_homepage_options _____ [gw0] linux -- Python 3.11.0 /opt/hostedtoolcache/Python/3.11.0/x64/bin/python

app_client = <datasette.utils.testing.TestClient object at 0x7f4c489269d0>

def test_homepage_options(app_client):
    response = app_client.get("/", method="OPTIONS")
  assert response.status == 405

E assert 200 == 405 E + where 200 = <datasette.utils.testing.TestResponse object at 0x7f4c4892f4d0>.status

/home/runner/work/datasette/datasette/tests/test_html.py:58: AssertionError ___ test_client_methods[options-/-405] ___ [gw1] linux -- Python 3.11.0 /opt/hostedtoolcache/Python/3.11.0/x64/bin/python

datasette = <datasette.app.Datasette object at 0x7fc33c227550> method = 'options', path = '/', expected_status = 405

@pytest.mark.asyncio
@pytest.mark.parametrize(
    "method,path,expected_status",
    [
        ("get", "/", 200),
        ("options", "/", 405),
        ("head", "/", 200),
        ("put", "/", 405),
        ("patch", "/", 405),
        ("delete", "/", 405),
    ],
)
async def test_client_methods(datasette, method, path, expected_status):
    client_method = getattr(datasette.client, method)
    response = await client_method(path)
    assert isinstance(response, httpx.Response)
  assert response.status_code == expected_status

E assert 200 == 405 E + where 200 = <Response [200 OK]>.status_code

/home/runner/work/datasette/datasette/tests/test_internals_datasette_client.py:29: AssertionError =============================== warnings summary =============================== tests/test_cli.py::test_inspect_cli_writes_to_file tests/test_cli.py::test_inspect_cli /home/runner/work/datasette/datasette/datasette/cli.py:163: DeprecationWarning: There is no current event loop loop = asyncio.get_event_loop()

tests/test_cli_serve_get.py: 2 warnings tests/test_cli.py: 12 warnings tests/test_crossdb.py: 1 warning /home/runner/work/datasette/datasette/datasette/cli.py:591: DeprecationWarning: There is no current event loop asyncio.get_event_loop().run_until_complete(ds.invoke_startup())

tests/test_cli_serve_get.py: 2 warnings tests/test_cli.py: 12 warnings tests/test_crossdb.py: 1 warning /home/runner/work/datasette/datasette/datasette/cli.py:594: DeprecationWarning: There is no current event loop asyncio.get_event_loop().run_until_complete(check_databases(ds))

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html =========================== short test summary info ============================ FAILED tests/test_html.py::test_homepage_options - assert 200 == 405 + where 200 = <datasette.utils.testing.TestResponse object at 0x7f4c4892f4d0>.status FAILED tests/test_internals_datasette_client.py::test_client_methods[options-/-405] - assert 200 == 405 + where 200 = <Response [200 OK]>.status_code ====== 2 failed, 1195 passed, 1 skipped, 32 warnings in 191.06s (0:03:11) ====== Error: Process completed with exit code 1. `` On reading https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/OPTIONS I feel like I should be a bit more thoughtful about how I treat OPTIONS - maybe it should work for every URL on the site, but return a204 No Content` header?

Comparing a few different sites:

``` ~ % curl -X OPTIONS https://www.google.com/ -i HTTP/2 405 allow: GET, HEAD date: Wed, 30 Nov 2022 18:18:15 GMT content-type: text/html; charset=UTF-8 server: gws content-length: 1592 x-xss-protection: 0 x-frame-options: SAMEORIGIN alt-svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"

<html lang=en> <meta charset=utf-8> <meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width"> <title>Error 405 (Method Not Allowed)!!1</title> <style> *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px} </style>

405. <ins>That’s an error.</ins>

The request method OPTIONS is inappropriate for the URL /. <ins>That’s all we know.</ins> ~ % curl -X OPTIONS https://www.mozilla.org/ -i HTTP/2 405 content-type: text/html; charset=utf-8 content-length: 0 server: meinheld/1.0.2 date: Wed, 30 Nov 2022 18:18:38 GMT allow: GET, HEAD x-frame-options: DENY content-security-policy: child-src 'self' *.mozilla.net *.mozilla.org *.mozilla.com www.googletagmanager.com www.google-analytics.com www.youtube-nocookie.com trackertest.org www.surveygizmo.com accounts.firefox.com accounts.firefox.com.cn www.youtube.com; connect-src 'self' *.mozilla.net *.mozilla.org *.mozilla.com www.googletagmanager.com www.google-analytics.com region1.google-analytics.com logs.convertexperiments.com 1003350.metrics.convertexperiments.com 1003343.metrics.convertexperiments.com sentry.prod.mozaws.net o1069899.sentry.io o1069899.ingest.sentry.io https://accounts.firefox.com/ stage.cjms.nonprod.cloudops.mozgcp.net cjms.services.mozilla.com; frame-src 'self' *.mozilla.net *.mozilla.org *.mozilla.com www.googletagmanager.com www.google-analytics.com www.youtube-nocookie.com trackertest.org www.surveygizmo.com accounts.firefox.com accounts.firefox.com.cn www.youtube.com; script-src 'self' *.mozilla.net *.mozilla.org *.mozilla.com 'unsafe-inline' 'unsafe-eval' www.googletagmanager.com www.google-analytics.com tagmanager.google.com www.youtube.com s.ytimg.com cdn-3.convertexperiments.com app.convert.com data.track.convertexperiments.com 1003350.track.convertexperiments.com 1003343.track.convertexperiments.com; img-src 'self' *.mozilla.net *.mozilla.org *.mozilla.com data: mozilla.org www.googletagmanager.com www.google-analytics.com adservice.google.com adservice.google.de adservice.google.dk creativecommons.org cdn-3.convertexperiments.com logs.convertexperiments.com images.ctfassets.net ad.doubleclick.net; style-src 'self' *.mozilla.net *.mozilla.org *.mozilla.com 'unsafe-inline' app.convert.com; default-src 'self' *.mozilla.net *.mozilla.org *.mozilla.com; font-src 'self' cache-control: max-age=600 expires: Wed, 30 Nov 2022 18:28:38 GMT x-backend-server: bedrock-prod-web-b95bc569d-grd25.iowa-a strict-transport-security: max-age=31536000 x-content-type-options: nosniff x-xss-protection: 1; mode=block referrer-policy: strict-origin-when-cross-origin via: 1.1 google, 1.1 6c90b631453c435bd0022caa657b67e8.cloudfront.net (CloudFront) x-cache: Error from cloudfront x-amz-cf-pop: SFO5-P2 x-amz-cf-id: A6-9mLztaE2tz840CbV9bXYiBMZRKEamDj6jGGEl1U7sg8egWfsDqg== ~ % curl -X OPTIONS https://example.com -i HTTP/2 200 allow: OPTIONS, GET, HEAD, POST cache-control: max-age=604800 content-type: text/html; charset=UTF-8 date: Wed, 30 Nov 2022 18:18:59 GMT expires: Wed, 07 Dec 2022 18:18:59 GMT server: EOS (vny/0451) content-length: 0 ```

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Make sure CORS works for write APIs 1469973742  
1332504654 https://github.com/simonw/datasette/issues/1922#issuecomment-1332504654 https://api.github.com/repos/simonw/datasette/issues/1922 IC_kwDOBm6k_c5PbGhO simonw 9599 2022-11-30T17:27:39Z 2022-11-30T17:27:39Z OWNER

I'll test this once it's deployed to https://latest.datasette.io/

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Make sure CORS works for write APIs 1469973742  
1332493004 https://github.com/simonw/datasette/issues/1922#issuecomment-1332493004 https://api.github.com/repos/simonw/datasette/issues/1922 IC_kwDOBm6k_c5PbDrM simonw 9599 2022-11-30T17:18:10Z 2022-11-30T17:18:10Z OWNER

Here's why:

https://github.com/simonw/datasette/blob/4ddd77e51254bda3bac990ea662bac2e6b29c5e0/datasette/views/base.py#L71-L79

That's code in BaseView - but it turns out the code that adds CORS headers is in the DataView subclass of that (which the various write API endpoints do not use).

https://github.com/simonw/datasette/blob/4ddd77e51254bda3bac990ea662bac2e6b29c5e0/datasette/views/base.py#L158-L162

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Make sure CORS works for write APIs 1469973742  
1332492092 https://github.com/simonw/datasette/issues/1922#issuecomment-1332492092 https://api.github.com/repos/simonw/datasette/issues/1922 IC_kwDOBm6k_c5PbDc8 simonw 9599 2022-11-30T17:17:21Z 2022-11-30T17:17:21Z OWNER

I tried running fetch() with a POST from a separate domain and got a browser error because it did a GET against the /db/-/create endpoint and the 405 method not supported response did not include the CORS headers.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Make sure CORS works for write APIs 1469973742  
1332310772 https://github.com/simonw/datasette/issues/1605#issuecomment-1332310772 https://api.github.com/repos/simonw/datasette/issues/1605 IC_kwDOBm6k_c5PaXL0 eyeseast 25778 2022-11-30T15:06:37Z 2022-11-30T15:06:37Z CONTRIBUTOR

I'll add issues for both and do a documentation PR.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Scripted exports 1108671952  
1331694246 https://github.com/simonw/datasette/issues/1605#issuecomment-1331694246 https://api.github.com/repos/simonw/datasette/issues/1605 IC_kwDOBm6k_c5PYAqm simonw 9599 2022-11-30T06:18:41Z 2022-11-30T06:18:41Z OWNER

Those sounds to me like they should be promoted to documented, supported internals.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Scripted exports 1108671952  
1331658629 https://github.com/simonw/datasette/issues/1918#issuecomment-1331658629 https://api.github.com/repos/simonw/datasette/issues/1918 IC_kwDOBm6k_c5PX3-F simonw 9599 2022-11-30T05:21:51Z 2022-11-30T05:21:51Z OWNER

Much better:

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
API explorer should list mutable databases first 1469044738  
1331657404 https://github.com/simonw/datasette/issues/1919#issuecomment-1331657404 https://api.github.com/repos/simonw/datasette/issues/1919 IC_kwDOBm6k_c5PX3q8 simonw 9599 2022-11-30T05:19:43Z 2022-11-30T05:19:43Z OWNER

This is the test: https://github.com/simonw/datasette/blob/8404b21556d133c89eda4bd1bf5335ed9a0785d6/tests/test_api_write.py#L342-L401

I'm suspicious that there's a timing error of some sort but I can't think what it might be.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Intermittent `test_delete_row` test failure  1469062686  
1331651721 https://github.com/simonw/datasette/issues/1916#issuecomment-1331651721 https://api.github.com/repos/simonw/datasette/issues/1916 IC_kwDOBm6k_c5PX2SJ simonw 9599 2022-11-30T05:10:27Z 2022-11-30T05:10:27Z OWNER

They should return 405 method not allowed with an {"ok":false, "error": "Method not allowed"} body.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
GET requests against POST endpoints should not 500 error 1469015001  
1331644751 https://github.com/simonw/datasette/issues/1917#issuecomment-1331644751 https://api.github.com/repos/simonw/datasette/issues/1917 IC_kwDOBm6k_c5PX0lP simonw 9599 2022-11-30T04:59:22Z 2022-11-30T04:59:22Z OWNER

Yeah it looks like I introduced this bug here:

https://github.com/simonw/datasette/commit/fb7e70d5e72a951efe4b29ad999d8915c032d021

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Don't allow writable API to edit the `_memory` database 1469043836  
1331644078 https://github.com/simonw/datasette/issues/1917#issuecomment-1331644078 https://api.github.com/repos/simonw/datasette/issues/1917 IC_kwDOBm6k_c5PX0au simonw 9599 2022-11-30T04:58:06Z 2022-11-30T04:58:06Z OWNER

The problem might actually be here:

https://github.com/simonw/datasette/blob/9f5321ff1eca58c469a45cc406d7eb5ad05accbd/datasette/app.py#L280-L281

is_mutable defaults to True, so this line should probably be:

python self.add_database(Database(self, is_mutable=False, is_memory=True), name="_memory")

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Don't allow writable API to edit the `_memory` database 1469043836  
1331479606 https://github.com/simonw/datasette/issues/1915#issuecomment-1331479606 https://api.github.com/repos/simonw/datasette/issues/1915 IC_kwDOBm6k_c5PXMQ2 simonw 9599 2022-11-30T00:09:06Z 2022-11-30T00:09:06Z OWNER

One last feature: I want to show an indication on the table page that the table has X seconds left to live.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Interactive demo of Datasette 1.0 write APIs 1468709531  
1331479328 https://github.com/simonw/datasette/issues/1915#issuecomment-1331479328 https://api.github.com/repos/simonw/datasette/issues/1915 IC_kwDOBm6k_c5PXMMg simonw 9599 2022-11-30T00:08:41Z 2022-11-30T00:08:41Z OWNER

Five minute has now passed and https://latest.datasette.io/ephemeral/new_table is gone.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Interactive demo of Datasette 1.0 write APIs 1468709531  
1331476246 https://github.com/simonw/datasette/issues/1915#issuecomment-1331476246 https://api.github.com/repos/simonw/datasette/issues/1915 IC_kwDOBm6k_c5PXLcW simonw 9599 2022-11-30T00:04:35Z 2022-11-30T00:08:24Z OWNER

The new https://github.com/simonw/datasette-ephemeral-tables plugin is live now: https://latest.datasette.io/ephemeral - you have to navigate through https://latest.datasette.io/login-as-root first

It work! I created a table using https://latest.datasette.io/-/api#path=%2Fephemeral%2F-%2Fcreate&json=%7B%0A++%22table%22%3A+%22new_table%22%2C%0A++%22columns%22%3A+%5B%0A++++%7B%0A++++++%22name%22%3A+%22id%22%2C%0A++++++%22type%22%3A+%22integer%22%0A++++%7D%2C%0A++++%7B%0A++++++%22name%22%3A+%22name%22%2C%0A++++++%22type%22%3A+%22text%22%0A++++%7D%0A++%5D%2C%0A++%22pk%22%3A+%22id%22%0A%7D&method=POST

The table should vanish in a few minutes.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Interactive demo of Datasette 1.0 write APIs 1468709531  
1331478611 https://github.com/simonw/datasette/issues/1915#issuecomment-1331478611 https://api.github.com/repos/simonw/datasette/issues/1915 IC_kwDOBm6k_c5PXMBT simonw 9599 2022-11-30T00:07:37Z 2022-11-30T00:07:37Z OWNER

Then I created an API token at https://latest.datasette.io/-/create-token and ran this:

curl -XPOST 'https://latest.datasette.io/ephemeral/new_table/-/insert' \ -H 'Authorization: Bearer xxx' \ -H 'Content-Type: application/json' \ -d '{"row": {"name": "NAME"}}' And it inserted a row into https://latest.datasette.io/ephemeral/new_table

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Interactive demo of Datasette 1.0 write APIs 1468709531  

Advanced export

JSON shape: default, array, newline-delimited, object

CSV options:

CREATE TABLE [issue_comments] (
   [html_url] TEXT,
   [issue_url] TEXT,
   [id] INTEGER PRIMARY KEY,
   [node_id] TEXT,
   [user] INTEGER REFERENCES [users]([id]),
   [created_at] TEXT,
   [updated_at] TEXT,
   [author_association] TEXT,
   [body] TEXT,
   [reactions] TEXT,
   [issue] INTEGER REFERENCES [issues]([id])
, [performed_via_github_app] TEXT);
CREATE INDEX [idx_issue_comments_issue]
                ON [issue_comments] ([issue]);
CREATE INDEX [idx_issue_comments_user]
                ON [issue_comments] ([user]);
Powered by Datasette · Queries took 1279.587ms · About: github-to-sqlite