datasette/tests
Claude 8b159144a5
Add Response.error() for JSON errors in the standard format
Response.error(messages, status=400) builds a JSON error response in
Datasette's standard error format, alongside Response.json/html/text.
messages can be a single string or a list. All internal error response
construction now uses it - the private views.base._error() helper is
gone and the verbose Response.json(error_body(...), status=...) sites
are converted. error_body() remains for the cases that merge the error
keys into a larger payload (the JSON renderer, handle_exception and the
permission debug payload builders).

Since Response is public plugin API, plugins that build JSON endpoints
now have an obvious way to return errors in the canonical shape.
Documented in the internals documentation, including the guidance to
raise Forbidden/NotFound/BadRequest/DatasetteError instead when the
error should content-negotiate.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GrHZSypDfMnym1tM5XJAFZ
2026-07-06 23:48:49 +00:00
..
plugins Support for <button> items in action menus 2026-06-14 15:58:37 -07:00
test_templates Fix handling of nested custom page wildcard paths, closes #996 2020-10-07 15:51:11 -07:00
__init__.py Broke up test_app into test_api and test_html 2017-12-15 04:08:24 -08:00
build_small_spatialite_db.py New run_sanity_checks mechanism, for SpatiLite 2019-05-11 15:55:30 -07:00
conftest.py Isolate Unix domain socket test server paths 2026-06-22 10:11:56 -07:00
ext.c Add new entrypoint option to --load-extensions. (#1789) 2022-08-23 11:34:30 -07:00
fixtures.py Enforce query ownership and remove canned query hook 2026-05-24 22:58:50 -07:00
spatialite.db New run_sanity_checks mechanism, for SpatiLite 2019-05-11 15:55:30 -07:00
test-datasette-load-plugins.sh fix (typo): Corrected spelling of 'environments' (#2268) 2024-02-19 14:41:32 -08:00
test_actions_sql.py Expanded analysis of SQL operations, refs #2748 2026-05-26 22:11:35 -07:00
test_actor_restriction_bug.py New PermissionSQL.restriction_sql mechanism for actor restrictions 2025-11-03 14:17:51 -08:00
test_allowed_many.py Switch to CTE to handle 600+ actions at once 2026-06-13 11:09:28 -07:00
test_allowed_resources.py Better test name 2026-05-23 17:07:47 -07:00
test_api.py Plain text SQL Interrupted errors in JSON responses 2026-07-06 23:34:17 +00:00
test_api_write.py Write endpoints parse the body as JSON regardless of Content-Type 2026-07-06 23:20:47 +00:00
test_auth.py Return 401 for invalid or expired bearer tokens 2026-07-04 15:18:12 +00:00
test_autocomplete.py Add "ok": true to every JSON object success response 2026-07-04 13:40:05 +00:00
test_base_view.py Unify JSON error responses into one canonical shape 2026-07-04 03:12:15 +00:00
test_cli.py Return canonical JSON error for Forbidden on JSON requests 2026-07-04 14:09:10 +00:00
test_cli_serve_get.py Add "ok": true to every JSON object success response 2026-07-04 13:40:05 +00:00
test_cli_serve_server.py Move HTTPS test to a bash script 2022-12-17 18:33:07 -08:00
test_column_types.py Write endpoints parse the body as JSON regardless of Content-Type 2026-07-06 23:20:47 +00:00
test_config_dir.py Convert /-/databases.json from top-level array to object 2026-07-04 13:43:44 +00:00
test_config_permission_rules.py Run black formatter 2025-10-25 15:38:07 -07:00
test_crossdb.py From 409 warnings down to 52 warnings. 2026-04-14 18:46:47 -07:00
test_csrf_middleware.py Normalize headers in CSRF checks, refs #2689 2026-04-14 19:24:38 -07:00
test_csv.py Black formatting 2026-02-17 13:30:24 -08:00
test_custom_pages.py Prevent open redirect via backslash in path (#2680) 2026-06-10 23:36:28 -07:00
test_datasette_https_server.sh More robust test_datasette_https_server.sh test 2026-06-22 10:11:56 -07:00
test_debug_autocomplete.py Autocomplete widget and /-/debug/autocomplete test page 2026-06-13 22:59:37 -07:00
test_default_deny.py Add regression test for --default-deny index 500 (#2644) 2026-06-10 23:36:28 -07:00
test_docs.py Add "ok": true to every JSON object success response 2026-07-04 13:40:05 +00:00
test_docs_plugins.py Call ds.close() in more places in tests 2026-04-16 20:25:58 -07:00
test_error_shape.py Plain text SQL Interrupted errors in JSON responses 2026-07-06 23:34:17 +00:00
test_extras.py Context.documented_fields() and extras doc-metadata enforcement 2026-06-11 07:47:15 -07:00
test_facets.py Respect metadata-defined facet ordering in sorted_facet_results (#2648) 2026-02-25 16:33:27 -08:00
test_fd_leak.py FD-leak regression test for Datasette.close() 2026-04-16 20:18:05 -07:00
test_filters.py Switch to ruff and fix all lint errors, refs #2630 2026-01-23 20:43:16 -08:00
test_fixtures.py datasette.fixtures module, closes #2733 2026-05-21 23:05:37 -07:00
test_html.py Unify page-size parameters on _size with table semantics 2026-07-04 17:54:03 +00:00
test_internal_db.py test_internal_foreign_key_references() fix for sqlite-utils 4.0rc3 2026-07-05 23:04:51 -07:00
test_internals_database.py Fix execute_isolated_fn() against immutable databases 2026-06-10 20:04:55 -07:00
test_internals_datasette.py Require permissions-debug for /-/threads 2026-07-04 16:22:41 +00:00
test_internals_datasette_client.py Add "ok": true to every JSON object success response 2026-07-04 13:40:05 +00:00
test_internals_request.py max_post_body_bytes setting, enforced for reuest.post_body() 2026-07-03 17:42:39 -07:00
test_internals_response.py Add Response.error() for JSON errors in the standard format 2026-07-06 23:48:49 +00:00
test_internals_urls.py Renamed base_url parameter to ds_base_url in tests 2026-06-16 14:25:42 -07:00
test_jump.py Autocomplete widget and /-/debug/autocomplete test page 2026-06-13 22:59:37 -07:00
test_label_column_for_table.py Detect single unique text column in label_column_for_table, closes #2458 2025-02-01 17:02:49 -08:00
test_load_extensions.py Introduce new /$DB/-/query endpoint, soft replaces /$DB?sql=... (#2363) 2024-07-15 10:33:51 -07:00
test_messages.py Introduce new /$DB/-/query endpoint, soft replaces /$DB?sql=... (#2363) 2024-07-15 10:33:51 -07:00
test_multipart.py Add request.form() for multipart form data and file uploads 2026-01-28 18:41:03 -08:00
test_package.py Upgrade Docker images to Python 3.11, closes #1853 2022-10-25 12:04:53 -07:00
test_permission_endpoints.py Unify page-size parameters on _size with table semantics 2026-07-04 17:54:03 +00:00
test_permissions.py Add unstable marker to undocumented JSON endpoints 2026-07-04 17:01:53 +00:00
test_playwright.py Make binary playwright test more robust 2026-07-05 22:46:00 -07:00
test_plugins.py Convert /-/plugins.json from top-level array to object 2026-07-04 13:42:24 +00:00
test_publish_cloudrun.py Black formatting 2026-02-17 13:30:24 -08:00
test_publish_heroku.py Upgrade to Python 3.11 on Heroku, refs #1905 2022-11-18 16:44:46 -08:00
test_pytest_autoclose_plugin.py Fix ruff lints in close-related tests 2026-04-16 20:34:48 -07:00
test_queries.py Remove has_more from query list JSON - next: null signals the end 2026-07-06 23:02:42 +00:00
test_restriction_sql.py Switch to ruff and fix all lint errors, refs #2630 2026-01-23 20:43:16 -08:00
test_routes.py Convert /-/databases.json from top-level array to object 2026-07-04 13:43:44 +00:00
test_schema_endpoints.py Add actor= parameter to datasette.client methods (#2688) 2026-04-14 18:31:57 -07:00
test_search_tables.py Prototype of new /-/jump menu plus plugin hook 2026-05-21 15:02:17 -07:00
test_spatialite.py Skip SpatiaLite test if no conn.enable_load_extension() 2022-09-05 17:09:57 -07:00
test_stored_queries.py Fix write query failing when a named parameter is called :sql (#2765) 2026-06-10 20:15:03 -07:00
test_success_envelope.py Add unstable marker to undocumented JSON endpoints 2026-07-04 17:01:53 +00:00
test_table_api.py Merge remote-tracking branch 'origin/main' into claude/json-api-docs-1-0-review-a3e83u 2026-07-06 22:25:27 +00:00
test_table_html.py Merge remote-tracking branch 'origin/main' into claude/json-api-docs-1-0-review-a3e83u 2026-07-06 22:25:27 +00:00
test_template_context.py Remove count truncated context test 2026-06-23 12:29:21 -07:00
test_token_handler.py Return 401 for invalid or expired bearer tokens 2026-07-04 15:18:12 +00:00
test_tracer.py Fix for trace_child_tasks exception handling 2026-06-12 13:21:58 -07:00
test_utils.py Support BLOB values in row edit UI 2026-07-03 16:09:27 -07:00
test_utils_check_callable.py Rename callable.py to check_callable.py, refs #2078 2023-05-25 11:49:40 -07:00
test_utils_permissions.py Black formatting 2026-02-17 13:30:24 -08:00
test_utils_sql_analysis.py Detect and disallow insert to virtual/shadow table 2026-05-28 08:36:59 -07:00
test_write_sql_operation_decisions.py Refactored write decision tests 2026-05-28 12:09:20 -07:00
test_write_wrapper.py Replace Janus queue with asyncio.Future 2026-05-16 11:45:43 -07:00
utils.py From 409 warnings down to 52 warnings. 2026-04-14 18:46:47 -07:00