You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by mi...@apache.org on 2026/09/05 03:05:08 UTC
(superset) branch master updated: fix(versioning): match version-history search on the change author name (#43835)
This is an automated email from the ASF dual-hosted git repository.
aminghadersohi 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 8963613e920 fix(versioning): match version-history search on the change author name (#43835)
8963613e920 is described below
commit 8963613e920daa8eff2dd62edc0d61a92b8abc3e
Author: Mike Bridge <mi...@preset.io>
AuthorDate: Fri Sep 4 21:05:00 2026 -0600
fix(versioning): match version-history search on the change author name (#43835)
Co-authored-by: Claude Fable 5 <no...@anthropic.com>
---
superset/versioning/activity/orchestrator.py | 19 ++++++++-
tests/unit_tests/versioning/test_activity.py | 63 ++++++++++++++++++++++++++++
2 files changed, 80 insertions(+), 2 deletions(-)
diff --git a/superset/versioning/activity/orchestrator.py b/superset/versioning/activity/orchestrator.py
index 1c71def71d4..641c23b78a5 100644
--- a/superset/versioning/activity/orchestrator.py
+++ b/superset/versioning/activity/orchestrator.py
@@ -180,12 +180,19 @@ def _parse_iso_datetime(value: str) -> datetime | None:
def _record_matches(record: dict[str, Any], q: str) -> bool:
"""Case-insensitive substring match for the ``q`` search filter,
over the human-meaningful surfaces of a decorated activity record:
- ``summary``, ``entity_name``, ``kind``, the joined ``path`` segments,
- and the JSON form of ``from_value`` / ``to_value`` (JSON, not Python
+ ``summary``, ``entity_name``, ``kind``, the change author's display
+ name (``changed_by`` first/last), the joined ``path`` segments, and
+ the JSON form of ``from_value`` / ``to_value`` (JSON, not Python
``str()``: the client searches the serialized text it renders, so
``false`` / ``null`` / double-quoted keys must match — and falsy
values like ``False`` / ``0`` must not collapse to unsearchable
empty strings).
+
+ The author name comes from the projected ``changed_by`` DTO, which
+ decoration redacts to ``None`` for a tombstoned related entity
+ (whose editor identity must not be disclosed) — so a redacted
+ record contributes no author text and stays unsearchable by author,
+ preserving that security contract.
"""
def _value_text(value: Any) -> str:
@@ -196,11 +203,19 @@ def _record_matches(record: dict[str, Any], q: str) -> bool:
except (TypeError, ValueError):
return str(value)
+ changed_by = record.get("changed_by") or {}
+ author_name = " ".join(
+ str(part)
+ for part in (changed_by.get("first_name"), changed_by.get("last_name"))
+ if part
+ )
+
needle = q.lower()
haystacks = (
record.get("summary") or "",
record.get("entity_name") or "",
record.get("kind") or "",
+ author_name,
" ".join(str(seg) for seg in (record.get("path") or [])),
_value_text(record.get("from_value")),
_value_text(record.get("to_value")),
diff --git a/tests/unit_tests/versioning/test_activity.py b/tests/unit_tests/versioning/test_activity.py
index 01c87a39837..4c8d55fa841 100644
--- a/tests/unit_tests/versioning/test_activity.py
+++ b/tests/unit_tests/versioning/test_activity.py
@@ -225,6 +225,13 @@ def test_decoration_redacts_record_from_reused_entity_id() -> None:
assert record["entity_name"] == ""
assert record["from_value"] is None
assert record["to_value"] is None
+ # The editor identity of the deleted related entity must be redacted at the
+ # decoration layer (render.py sets ``changed_by = None``), so the seeded
+ # author "Ada Lovelace" is suppressed and cannot be surfaced or searched.
+ # Without this assertion the redaction can regress silently.
+ assert record["changed_by"] is None
+ assert "first_name" not in record
+ assert "last_name" not in record
def test_bounded_heap_merges_newer_rows_from_later_id_chunks() -> None:
@@ -800,6 +807,62 @@ def test_record_matches_falsy_values_and_json_form() -> None:
assert _record_matches(nested, '"label"') # JSON double-quoted key
+def test_record_matches_searches_author_name() -> None:
+ """The q filter also matches the change author's display name from the
+ projected ``changed_by`` DTO (sc-119374: author-scoped search returned
+ "No actions found" because the author was absent from the haystack)."""
+ from superset.versioning.activity.orchestrator import _record_matches
+
+ record = {
+ "summary": "",
+ "entity_name": "Sales",
+ "kind": "field",
+ "path": ["params"],
+ "from_value": None,
+ "to_value": None,
+ "changed_by": {
+ "id": 1,
+ "first_name": "Test Primary",
+ "last_name": "Contributor",
+ },
+ }
+ assert _record_matches(record, "Primary") # first-name substring
+ assert _record_matches(record, "contributor") # last name, case-insensitive
+ assert _record_matches(record, "Test Primary Contributor") # full name
+ assert not _record_matches(record, "Nonexistent Author")
+
+
+def test_record_matches_author_partial_and_missing_name() -> None:
+ """A user with only one name part still matches on it, and a record
+ whose author is redacted/absent (``changed_by`` is None — the
+ tombstoned-related-entity security contract) contributes no author
+ text and is not matchable by author."""
+ from superset.versioning.activity.orchestrator import _record_matches
+
+ first_only = {
+ "summary": "",
+ "entity_name": "",
+ "kind": "field",
+ "path": [],
+ "from_value": None,
+ "to_value": None,
+ "changed_by": {"id": 2, "first_name": "Ada", "last_name": None},
+ }
+ assert _record_matches(first_only, "ada")
+
+ redacted = {**first_only, "changed_by": None}
+ assert not _record_matches(redacted, "ada")
+
+ # A present DTO with both name parts null (a user row with no names) is
+ # distinct from redaction: it yields an empty author name and is likewise
+ # unsearchable by author, without matching on the literal 'None'.
+ nameless = {
+ **first_only,
+ "changed_by": {"id": 3, "first_name": None, "last_name": None},
+ }
+ assert not _record_matches(nameless, "none")
+
+
def test_build_summary_meta_headline_branches() -> None:
"""The __meta__ headline dispatches on the transaction's action_kind
(path is pure navigation): restore renders 'restored to version N'