fix: populate dropdown cache on demand for limited-visibility users (ENG-7919)#108
Open
tvansteenburgh wants to merge 1 commit into
Open
Conversation
…ENG-7919) [ENG-7919](https://stacklet.atlassian.net/browse/ENG-7919) ### what When validating a query-backed dropdown parameter, run the dropdown query on demand (`run_if_not_cached=True`) if it isn't already cached for the requesting user's db_role, instead of failing. ### why Limited-visibility (SSO/RLS) users each connect under a distinct per-user db_role, and cached query results are row-level-isolated by db_role. The parameter-validation path called `dropdown_values(..., run_if_not_cached=False)`, so a user whose db_role had no cached dropdown result raised `DropdownSubqueryError` ("cached results not found"), which was swallowed into a misleading `InvalidParameterError` ("parameter values are incompatible with their definitions"). Every widget on a dashboard with query-backed dropdowns then errored for that user. The two dropdown-fetch endpoints already pass `run_if_not_cached=True`; only the validation call site did not. The manual workaround (each user opening the dropdown queries and clicking Refresh) populated their own db_role's cache, but had to be repeated per user. This makes that automatic, per db_role, at validation time. The on-demand subquery runs as the user, so RLS scopes the cached result correctly. ### testing Added a regression unit test asserting the query-parameter validator invokes `dropdown_values` with `run_if_not_cached=True`. Ran the module via `just backend-test tests/models/test_parameterized_query.py` -> 38 passed. ### docs No user-facing docs needed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.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.
ENG-7919
what
When validating a query-backed dropdown parameter, run the dropdown query
on demand (
run_if_not_cached=True) if it isn't already cached for therequesting user's db_role, instead of failing.
why
Limited-visibility (SSO/RLS) users each connect under a distinct per-user
db_role, and cached query results are row-level-isolated by db_role. The
parameter-validation path called
dropdown_values(..., run_if_not_cached=False),so a user whose db_role had no cached dropdown result raised
DropdownSubqueryError("cached results not found"), which was swallowed intoa misleading
InvalidParameterError("parameter values are incompatible withtheir definitions"). Every widget on a dashboard with query-backed dropdowns
then errored for that user.
The two dropdown-fetch endpoints already pass
run_if_not_cached=True; only thevalidation call site did not. The manual workaround (each user opening the
dropdown queries and clicking Refresh) populated their own db_role's cache, but
had to be repeated per user. This makes that automatic, per db_role, at
validation time. The on-demand subquery runs as the user, so RLS scopes the
cached result correctly.
testing
Added a regression unit test asserting the query-parameter validator invokes
dropdown_valueswithrun_if_not_cached=True. Ran the module viajust backend-test tests/models/test_parameterized_query.py-> 38 passed.docs
No user-facing docs needed.
🤖 Generated with Claude Code