actions_sql: always emit the anon_rules CTE so empty-anon path doesn't 500#2722
Open
c-tonneslan wants to merge 2 commits into
Open
actions_sql: always emit the anon_rules CTE so empty-anon path doesn't 500#2722c-tonneslan wants to merge 2 commits into
c-tonneslan wants to merge 2 commits into
Conversation
Closes simonw#2712. Database.table_counts has a count_limit=10000 cap so the runtime UI doesn't sit on huge tables. The datasette inspect CLI shared that path, so the JSON it persists capped every row count at 10001. Add an exact=True path that issues a plain SELECT COUNT(*) (the same query inspect_tables in inspect.py uses) and have the CLI call that. The result also doesn't get cached on the Database, since a precomputed count is wrong if the file changes later. Signed-off-by: Charlie Tonneslan <cst0520@gmail.com>
Closes simonw#2644. anon_rules was only added when at least one anonymous permission rule came back from the hooks. With --default-deny and no config file all the hooks return nothing, but the downstream anon_child_lvl / anon_parent_lvl / anon_global_lvl CTEs LEFT JOIN anon_rules unconditionally, so the full query was invalid SQL and the index pages returned 500. Emit an empty CTE with matching columns in the no-rules case. Signed-off-by: Charlie Tonneslan <cst0520@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2644.
anon_ruleswas only added when at least one anonymous permission rule came back from the hooks. With--default-denyand no config file the hooks all return nothing, but the downstreamanon_child_lvl/anon_parent_lvl/anon_global_lvlCTEsLEFT JOIN anon_rulesunconditionally, so the full query was invalid SQL and the index pages returned 500.Emitting an empty CTE with the expected columns in the no-rules case keeps the LEFT JOINs happy without changing the result. Regression test under
test_default_deny_no_config_index_pages_dont_500.