You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ru...@apache.org on 2026/09/10 02:58:59 UTC
(superset) branch master updated: fix(rison-filters): only catch ParserException when parsing filters (#43076)
This is an automated email from the ASF dual-hosted git repository.
rusackas pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/master by this push:
new 64205357d25 fix(rison-filters): only catch ParserException when parsing filters (#43076)
64205357d25 is described below
commit 64205357d2570288ff08c18bc519bf04ddbb6673
Author: Aadhya Puttur <pu...@gmail.com>
AuthorDate: Wed Sep 9 19:58:52 2026 -0700
fix(rison-filters): only catch ParserException when parsing filters (#43076)
Co-authored-by: Devin AI <15...@users.noreply.github.com>
Co-authored-by: bot_apk <ap...@cognition.ai>
Co-authored-by: Joe Li <jo...@preset.io>
---
superset/utils/rison_filters.py | 6 ++++--
tests/unit_tests/utils/test_rison_filters.py | 25 +++++++++++++++++++++++++
2 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/superset/utils/rison_filters.py b/superset/utils/rison_filters.py
index b08e48aba0a..c22e8cbdf4d 100644
--- a/superset/utils/rison_filters.py
+++ b/superset/utils/rison_filters.py
@@ -27,6 +27,7 @@ from typing import Any, Optional, Union
import prison
from flask import has_request_context, request
+from prison.decoder import ParserException
logger = logging.getLogger(__name__)
@@ -106,13 +107,14 @@ class RisonFilterParser:
try:
filters_obj = prison.loads(filter_string)
- return self._convert_to_adhoc_filters(filters_obj)
- except Exception:
+ except ParserException:
logger.warning(
"Failed to parse Rison filters: %s", filter_string, exc_info=True
)
return []
+ return self._convert_to_adhoc_filters(filters_obj)
+
def _convert_to_adhoc_filters(
self, filters_obj: Union[dict[str, Any], list[Any], Any]
) -> list[dict[str, Any]]:
diff --git a/tests/unit_tests/utils/test_rison_filters.py b/tests/unit_tests/utils/test_rison_filters.py
index 5179ce9bedb..d8830d21461 100644
--- a/tests/unit_tests/utils/test_rison_filters.py
+++ b/tests/unit_tests/utils/test_rison_filters.py
@@ -16,6 +16,10 @@
# under the License.
"""Unit tests for Rison filter parser."""
+import logging
+
+import pytest
+
from superset.utils.rison_filters import RisonFilterParser
@@ -132,6 +136,27 @@ def test_invalid_rison():
assert parser.parse("(unclosed") == []
+def test_invalid_rison_logs_warning(caplog):
+ parser = RisonFilterParser()
+ with caplog.at_level(logging.WARNING):
+ assert parser.parse("(unclosed") == []
+ assert "Failed to parse Rison filters" in caplog.text
+
+
+def test_conversion_errors_are_not_swallowed(mocker):
+ """An unexpected error in the conversion logic must surface rather than
+ being reported as a Rison parsing failure."""
+ parser = RisonFilterParser()
+ mocker.patch.object(
+ parser,
+ "_convert_to_adhoc_filters",
+ side_effect=RuntimeError("boom"),
+ )
+
+ with pytest.raises(RuntimeError, match="boom"):
+ parser.parse("(country:USA)")
+
+
def test_or_branch_escapes_string_literals():
"""OR-branch SQL must escape apostrophes; otherwise a value like
`O'Brien'); DROP TABLE x; --` could close out a literal and inject.