Make filters, actions and display_rows extras internal

These three extras return values that exist for the HTML templates -
a Filters instance, an async function and markupsafe/sqlite3.Row data
- so requesting them on a .json page returned a 500 serialization
error, while the generated documentation and ?_extra=extras both
advertised them as API surface. They are now public=False: ignored
like any unknown name on JSON requests, omitted from the docs and the
extras list, and still resolved for the HTML view via the new
include_internal flag on ExtraRegistry.resolve().

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Simon Willison 2026-06-10 22:50:44 -07:00
commit b635dc53f4
5 changed files with 44 additions and 21 deletions

View file

@ -117,6 +117,24 @@ async def test_query_extras_for_stored_query(ds_client):
}
@pytest.mark.parametrize("extra", ["filters", "actions", "display_rows"])
@pytest.mark.asyncio
async def test_html_only_extras_are_not_available_via_json(ds_client, extra):
# These extras exist for the HTML view; their values are not JSON
# serializable so they are internal, not part of the JSON API
response = await ds_client.get(f"/fixtures/facetable.json?_extra={extra}")
assert response.status_code == 200
assert extra not in response.json()
@pytest.mark.asyncio
async def test_html_only_extras_are_not_advertised(ds_client):
response = await ds_client.get("/fixtures/facetable.json?_extra=extras")
assert response.status_code == 200
names = {e["name"] for e in response.json()["extras"]}
assert {"filters", "actions", "display_rows"}.isdisjoint(names)
def test_query_extra_private_for_arbitrary_sql():
with make_app_client(config={"allow_sql": {"id": "root"}}) as client:
cookies = {"ds_actor": client.actor_cookie({"id": "root"})}