Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Returns 404 instead of 500 for unknown dashboard filter state keys #17878

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions superset/dashboards/filter_state/commands/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@
class GetFilterStateCommand(GetKeyValueCommand):
def get(self, resource_id: int, key: str, refresh_timeout: bool) -> Optional[str]:
dashboard = DashboardDAO.get_by_id_or_slug(str(resource_id))
if dashboard:
entry: Entry = cache_manager.filter_state_cache.get(
cache_key(resource_id, key)
)
if refresh_timeout:
cache_manager.filter_state_cache.set(key, entry)
return entry["value"]
return None
entry: Entry = cache_manager.filter_state_cache.get(
cache_key(resource_id, key)
) or {}
if dashboard and entry and refresh_timeout:
cache_manager.filter_state_cache.set(key, entry)
michael-s-molina marked this conversation as resolved.
Show resolved Hide resolved
return entry.get("value")
4 changes: 2 additions & 2 deletions tests/integration_tests/dashboards/filter_state/api_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ def test_put_not_owner(client, dashboard_id: int):
assert resp.status_code == 403


def test_get_key_not_found(client):
def test_get_key_not_found(client, dashboard_id: int):
login(client, "admin")
resp = client.get("unknown-key")
resp = client.get(f"api/v1/dashboard/{dashboard_id}/filter_state/unknown-key/")
assert resp.status_code == 404


Expand Down