Commit graph

45 commits

Author SHA1 Message Date
Alex Garcia
745b7872b8 Remove the hand-rolled tracer now that OpenTelemetry covers the same ground
Datasette had two tracing systems since the OpenTelemetry spans landed. The
hand-rolled one measures the wrong thing - issue 1730, open since 2022, is
about exactly that - and it cannot be rebuilt on top of the new spans without
core owning a TracerProvider, which is the one thing the OTel design refuses
to do. Rather than carry duplicate instrumentation on the db.execute() hot
path indefinitely, the old system goes.

Deleted: datasette/tracer.py, the trace_debug setting, the AsgiTracer
response-rewriting middleware and the ?_trace=1 query-string argument.

- datasette/database.py: the four `with trace(...)` wrappers PR 1 deliberately
  nested the OTel spans inside are removed and the bodies dedented. That also
  retires the `# noqa: SIM117` comments those wrappers required - a leftover
  unnecessary noqa trips ruff's RUF100 - and `kwargs["count"] = count` in
  execute_write_many, which fed the old tracer only. `git diff -w` on this file
  shows nothing but the deleted lines.
- datasette/views/base.py: stream_csv() still read ?_trace=1 to wrap CSV output
  in an HTML <textarea> debug page. That whole branch, including the
  EscapeHtmlWriter selection and the conditional content-type, is gone. The
  EscapeHtmlWriter class itself stays in datasette.utils - it is an importable
  public name and removing it would widen the API break.
- .github/workflows/deploy-latest.yml no longer passes --setting trace_debug 1.
  Worth stating precisely, because the ticket claimed otherwise: this would not
  have broken the deploy. Setting.convert() in cli.py only rewrites a bare name
  to settings.<name> for *known* settings, so `--setting trace_debug 1` would
  have been silently accepted as a meaningless top-level config key. The flag is
  removed because it is dead, not because it errors.

Tests. tests/test_tracer.py is deleted outright (6 items). Four other tests used
?_trace=1 as an assertion instrument rather than testing tracing:

- test_csv_trace tested the trace mechanism itself - deleted.
- test_table_csv_stream_does_not_calculate_facets,
  test_table_csv_stream_does_not_calculate_counts and
  test_nocount_nofacet_if_shape_is_object test real behaviour, and are rebuilt
  against captured spans. All three had silently stopped being able to fail: the
  facets test looked for "select content, count(*) as n", which facet suggestion
  has not emitted since it moved to a `with limited as (...)` CTE, and none of
  the three requested the count or facet work whose suppression they claim to
  check. The rebuilt versions ask for it explicitly, match strings the current
  SQL contains, and carry a guard assertion so an empty span list cannot
  masquerade as a pass. Each was confirmed to fail with the covered code broken.
- test_trace_correctly_escaped is kept, renamed test_query_page_escapes_sql,
  with ?_trace=1 dropped. It ran against ds_client, which has no trace_debug, so
  it never exercised the tracer - what it actually covered is the query page
  echoing user SQL into HTML, the surface of the two reflected-XSS advisories in
  issue 1360, and nothing else in the suite covers it. Deleting it would have
  quietly dropped that.

tests/test_utils.py's pairs_to_nested_config case used settings.trace_debug to
check that a later key overrides an earlier one; it now uses template_debug
rather than losing the case.

Docs: the datasette.tracer section of internals.rst, the trace_debug section of
settings.rst, the ?_trace=1 entries in json_api.rst and introspection.rst, and
the regenerated cli-reference.rst. changelog.rst gets a breaking-change entry
and keeps all its historical ?_trace=1 entries - two of them had to lose a
:ref: role pointing at a label this commit deletes, or Sphinx warns on every
build.

2368 passed, 39 skipped, 6 xfailed, 15 xpassed, 140 subtests, against 2375 /
141 before. Net -7 tests, fully accounted for: -6 test_tracer.py, -1
test_csv_trace, -1 test_trace_correctly_escaped, +1 test_query_page_escapes_sql.
The lost subtest is the per-setting case trace_debug generated in
test_settings_are_documented.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-01 16:24:35 -07:00
Simon Willison
58c07cc264 max_post_body_bytes setting, enforced for reuest.post_body()
Closes #2823
2026-07-03 17:42:39 -07:00
Simon Willison
23a640d38b
datasette serve --default-deny option (#2593)
Closes #2592
2025-11-12 16:14:21 -08:00
Simon Willison
f12f6cc2ab
Get publish cloudrun working with latest Cloud Run (#2581)
Refs:
- #2511

Filter out bad services, refs:
- https://github.com/simonw/datasette/pull/2581#issuecomment-3492243400
2025-11-05 09:28:41 -08:00
Simon Willison
ce464da34b datasette --get --headers option, closes #2578 2025-11-04 18:12:15 -08:00
Simon Willison
c0b5ce04c3 Ran cog 2025-10-24 10:32:18 -07:00
Simon Willison
c06e05b7db New --root mechanism with datasette.root_enabled, closes #2521 2025-10-24 10:32:18 -07:00
Simon Willison
832f76ce26 Documentation for datasette serve environment variables
Refs #2422, #2424
2024-09-09 09:18:47 -07:00
Alex Garcia
92b8bf38c0
Add new --internal internal.db option, deprecate legacy _internal database
Refs:
- #2157 
---------

Co-authored-by: Simon Willison <swillison@gmail.com>
2023-08-28 20:24:23 -07:00
Simon Willison
d8351b08ed datasette --get --actor 'JSON' option, closes #2153
Refs #2154
2023-08-28 13:15:38 -07:00
Simon Willison
d9aad1fd04
-s/--setting x y gets merged into datasette.yml, refs #2143, #2156
This change updates the `-s/--setting` option to `datasette serve` to allow it to be used to set arbitrarily complex nested settings in a way that is compatible with the new `-c datasette.yml` work happening in:
- #2143

It will enable things like this:
```
datasette data.db --setting plugins.datasette-ripgrep.path "/home/simon/code"
```
For the moment though it just affects [settings](https://docs.datasette.io/en/1.0a4/settings.html) - so you can do this:
```
datasette data.db --setting settings.sql_time_limit_ms 3500
```
I've also implemented a backwards compatibility mechanism, so if you use it this way (the old way):
```
datasette data.db --setting sql_time_limit_ms 3500
```
It will notice that the setting you passed is one of Datasette's core settings, and will treat that as if you said `settings.sql_time_limit_ms` instead.
2023-08-28 13:06:14 -07:00
Simon Willison
64fd1d788e Applied Cog, refs #2143, #2149 2023-08-22 19:57:46 -07:00
Alex Garcia
17ec309e14
Start datasette.json, re-add --config, rm settings.json
The first step in defining the new `datasette.json/yaml` configuration mechanism.

Refs #2093, #2143, #493
2023-08-22 18:26:11 -07:00
Simon Willison
943df09dcc Remove all remaining "$ " prefixes from docs, closes #2140
Also document sqlite-utils create-view
2023-08-11 10:44:34 -07:00
Simon Willison
4a42476bb7 datasette plugins --requirements, closes #2133 2023-08-09 15:04:16 -07:00
Simon Willison
0818182399 Update cli-reference for editable change, refs #2106 2023-07-26 11:52:57 -07:00
Simon Willison
278ac91a4d datasette install -e option, closes #2106 2023-07-22 11:42:46 -07:00
Simon Willison
1ad92a1d87 datasette install -r requirements.txt, closes #2033 2023-03-06 14:27:30 -08:00
Simon Willison
c41278b46f default_allow_sql setting, closes #1409
Refs #1410
2023-01-04 16:51:26 -08:00
Simon Willison
d4cc1374f4 Improved --help for create-token, refs #1947 2022-12-13 14:28:59 -08:00
Simon Willison
c13dada2f8 datasette --get --token option, closes #1946, refs #1855 2022-12-12 20:36:42 -08:00
Simon Willison
14f1cc4984 Update CLI reference help, refs #1855 2022-12-12 20:21:48 -08:00
Simon Willison
b8fc8e2cd7
Merge branch 'main' into 1.0-dev 2022-11-29 11:34:39 -08:00
Simon Willison
72ac9bf82f --generate-dir option to publish heroku, refs #1905 2022-11-18 16:34:33 -08:00
Simon Willison
4f16e14d7a Update cog 2022-10-30 14:53:33 -07:00
Simon Willison
c35859ae3d API for bulk inserts, closes #1866 2022-10-29 23:03:45 -07:00
Simon Willison
51c436fed2 First draft of insert row write API, refs #1851 2022-10-26 20:57:02 -07:00
Simon Willison
c7956eed77 datasette create-token command, refs #1859 2022-10-25 21:26:12 -07:00
Simon Willison
c23fa850e7 allow_signed_tokens setting, closes #1856 2022-10-25 19:55:47 -07:00
Simon Willison
ff9c87197d Fixed Sphinx warnings on cli-reference page 2022-09-06 11:26:21 -07:00
Simon Willison
456dc155d4 Ran cog, refs #1789 2022-08-23 11:40:48 -07:00
Simon Willison
6c0ba7c00c Improved CLI reference documentation, refs #1787 2022-08-18 14:52:04 -07:00
Simon Willison
82167105ee --min-instances and --max-instances Cloud Run publish options, closes #1779 2022-08-14 10:07:30 -07:00
Simon Willison
3508bf7875 --nolock mode to ignore locked files, closes #1744 2022-05-17 12:40:25 -07:00
Simon Willison
e64d14e413 Use type integer for --timeout, refs #1717 2022-04-24 07:09:08 -07:00
Simon Willison
4bd3a30e1e Update cog docs for publish cloudrun, refs #1717 2022-04-24 07:04:11 -07:00
Simon Willison
32963018e7 Updated documentation to remove hash_urls, refs #1661 2022-03-18 17:33:06 -07:00
Simon Willison
3664ddd400 Replace update-docs-help.py with cog, closes #1598 2022-01-13 16:47:53 -08:00
Simon Willison
ab7d6a7179 Updated settings help URL to avoid redirect 2022-01-13 16:38:16 -08:00
Simon Willison
714b4df1b1 Fixed reStructuredText warning, refs #1594 2022-01-13 16:36:28 -08:00
Simon Willison
515f8d38eb Help summaries for publish cloudrun/heroku 2022-01-13 16:12:54 -08:00
Simon Willison
8cf4b77a92 Better copy for 'datasette plugins --help' 2022-01-13 16:11:07 -08:00
Simon Willison
8f5c44a166 Better --help summaries for install and uninstall 2022-01-13 16:09:38 -08:00
Simon Willison
88bc2ceae1 --help summary for 'datasette inspect', closes #1597 2022-01-13 16:07:30 -08:00
Simon Willison
4b23f01f3e CLI reference docs, maintained by cog - refs #1594 2022-01-13 13:35:54 -08:00