Skip to content

Commit

Permalink
fix: Returns 404 instead of 500 for unknown dashboard filter state keys
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-s-molina committed Dec 29, 2021
1 parent ef57bd1 commit 030d322
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions superset/dashboards/filter_state/commands/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ def get(self, resource_id: int, key: str, refresh_timeout: bool) -> Optional[str
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"]
if entry:
if refresh_timeout:
cache_manager.filter_state_cache.set(key, entry)
return entry["value"]
return None
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

0 comments on commit 030d322

Please sign in to comment.