From e5e7d56c672fdbea832b4c05a7b2378083194ee4 Mon Sep 17 00:00:00 2001 From: Timotius Date: Thu, 26 Nov 2026 12:41:39 +1300 Subject: [PATCH 1/6] feat: DM-4104 Add json_string_prefix_lengths to file locator results --- HISTORY.rst | 4 ++++ datamasque/client/models/discovery.py | 4 ++++ tests/test_discovery.py | 26 ++++++++++++++++++++++++++ 3 files changed, 34 insertions(+) diff --git a/HISTORY.rst b/HISTORY.rst index 1a55312..e5072f7 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -5,6 +5,10 @@ History 1.7.0 (unreleased) ------------------ +* Added ``json_string_prefix_lengths`` to ``FileDiscoveryLocatorResult``: + where a JSON or NDJSON locator passes through a string that holds JSON. + Each number ``n`` means the first ``n`` segments of the locator held such a string. + It is ``None`` when the locator passes through none, and from a server that predates the field. * Added an optional ``instance`` field to ``DatabaseConnectionConfig``: the SQL Server named instance, taken from the Instance input in the connection form's advanced settings. It round-trips through ``list_connections`` and ``create_or_update_connection``, diff --git a/datamasque/client/models/discovery.py b/datamasque/client/models/discovery.py index f2ccbd0..f75cfd7 100644 --- a/datamasque/client/models/discovery.py +++ b/datamasque/client/models/discovery.py @@ -476,6 +476,10 @@ class FileDiscoveryLocatorResult(BaseModel): data_types: list[str] safe_data_preview: Optional[SafeDataPreview] = None value_count: Optional[int] = None + # Each `n` means the first `n` segments of `locator` held a string that holds JSON, + # and the rest of `locator` is the path inside it. + # None when the locator passes through no such string, and from a server that predates the field. + json_string_prefix_lengths: Optional[list[int]] = None class FileDiscoveryFile(BaseModel): diff --git a/tests/test_discovery.py b/tests/test_discovery.py index 7f7d328..7c35b2b 100644 --- a/tests/test_discovery.py +++ b/tests/test_discovery.py @@ -1094,6 +1094,32 @@ def test_file_discovery_value_counts_parse(): assert result.results[0].value_count == 30 +def test_file_discovery_json_string_prefix_lengths_parse(): + """A locator through a string that holds JSON carries its prefix lengths; one from an older server has none.""" + + def locator_result(**extra: object) -> dict: + return { + "locator": ["*", "event_payload", "email"], + "data_types": ["str"], + "matches": [{"flagged_by": "MDD", "description": "Email", "label": "email"}], + **extra, + } + + result = FileDiscoveryResult.model_validate( + { + "id": 10, + "connection": {"id": "conn-1", "name": "my files"}, + "file_type": "json", + "files": [{"path": "data/events.json", "file_type": "json"}], + "results": [locator_result(json_string_prefix_lengths=[2]), locator_result()], + } + ) + + through_a_string, from_an_older_server = result.results + assert through_a_string.json_string_prefix_lengths == [2] + assert from_an_older_server.json_string_prefix_lengths is None + + def test_file_discovery_uncounted_values_parse(): """A file type that holds no values reports the reason, no counts, and a null count on the locator.""" result = FileDiscoveryResult.model_validate( From 247eb776fe1bbdb04f0681fdf96b168bd6848b30 Mon Sep 17 00:00:00 2001 From: Timotius Date: Fri, 27 Nov 2026 01:34:30 +1300 Subject: [PATCH 2/6] chore: DM-4104 Release 1.7.0 --- HISTORY.rst | 2 +- pyproject.toml | 2 +- uv.lock | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index e5072f7..56eed2c 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -2,7 +2,7 @@ History ======= -1.7.0 (unreleased) +1.7.0 (2026-11-27) ------------------ * Added ``json_string_prefix_lengths`` to ``FileDiscoveryLocatorResult``: diff --git a/pyproject.toml b/pyproject.toml index 6f3eaed..7fced60 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "datamasque-python" -version = "1.6.0" +version = "1.7.0" description = "Official Python client for the DataMasque data-masking API." authors = [ { name = "DataMasque Ltd" }, diff --git a/uv.lock b/uv.lock index 0fb45ec..c712118 100644 --- a/uv.lock +++ b/uv.lock @@ -419,7 +419,7 @@ toml = [ [[package]] name = "datamasque-python" -version = "1.6.0" +version = "1.7.0" source = { editable = "." } dependencies = [ { name = "pydantic" }, From 3083d25654f48e3882287ecac90fd6840e9390f8 Mon Sep 17 00:00:00 2001 From: Timotius Date: Fri, 27 Nov 2026 20:00:03 +1300 Subject: [PATCH 3/6] feat!: DM-4104 Rename json_string_prefix_lengths to json_string_indexes --- HISTORY.rst | 4 ++-- datamasque/client/models/discovery.py | 6 +++--- tests/test_discovery.py | 10 +++++----- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 56eed2c..450d3ed 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -5,9 +5,9 @@ History 1.7.0 (2026-11-27) ------------------ -* Added ``json_string_prefix_lengths`` to ``FileDiscoveryLocatorResult``: +* Added ``json_string_indexes`` to ``FileDiscoveryLocatorResult``: where a JSON or NDJSON locator passes through a string that holds JSON. - Each number ``n`` means the first ``n`` segments of the locator held such a string. + Each number is the index, counted from 0, of a locator segment that held such a string. It is ``None`` when the locator passes through none, and from a server that predates the field. * Added an optional ``instance`` field to ``DatabaseConnectionConfig``: the SQL Server named instance, taken from the Instance input in the connection form's advanced settings. diff --git a/datamasque/client/models/discovery.py b/datamasque/client/models/discovery.py index f75cfd7..516560c 100644 --- a/datamasque/client/models/discovery.py +++ b/datamasque/client/models/discovery.py @@ -476,10 +476,10 @@ class FileDiscoveryLocatorResult(BaseModel): data_types: list[str] safe_data_preview: Optional[SafeDataPreview] = None value_count: Optional[int] = None - # Each `n` means the first `n` segments of `locator` held a string that holds JSON, - # and the rest of `locator` is the path inside it. + # The indexes, counted from 0, of the `locator` segments that held a string that holds JSON; + # the segments after each one are the path inside it. # None when the locator passes through no such string, and from a server that predates the field. - json_string_prefix_lengths: Optional[list[int]] = None + json_string_indexes: Optional[list[int]] = None class FileDiscoveryFile(BaseModel): diff --git a/tests/test_discovery.py b/tests/test_discovery.py index 7c35b2b..668f4c0 100644 --- a/tests/test_discovery.py +++ b/tests/test_discovery.py @@ -1094,8 +1094,8 @@ def test_file_discovery_value_counts_parse(): assert result.results[0].value_count == 30 -def test_file_discovery_json_string_prefix_lengths_parse(): - """A locator through a string that holds JSON carries its prefix lengths; one from an older server has none.""" +def test_file_discovery_json_string_indexes_parse(): + """A locator through a string that holds JSON carries its string indexes; one from an older server has none.""" def locator_result(**extra: object) -> dict: return { @@ -1111,13 +1111,13 @@ def locator_result(**extra: object) -> dict: "connection": {"id": "conn-1", "name": "my files"}, "file_type": "json", "files": [{"path": "data/events.json", "file_type": "json"}], - "results": [locator_result(json_string_prefix_lengths=[2]), locator_result()], + "results": [locator_result(json_string_indexes=[1]), locator_result()], } ) through_a_string, from_an_older_server = result.results - assert through_a_string.json_string_prefix_lengths == [2] - assert from_an_older_server.json_string_prefix_lengths is None + assert through_a_string.json_string_indexes == [1] + assert from_an_older_server.json_string_indexes is None def test_file_discovery_uncounted_values_parse(): From 1eedb372bb8e14ef8eaac52ff197c27a9ff2e2a2 Mon Sep 17 00:00:00 2001 From: Timotius Date: Fri, 27 Nov 2026 20:08:59 +1300 Subject: [PATCH 4/6] docs: DM-4104 Shorten the json_string_indexes description --- HISTORY.rst | 5 ++--- datamasque/client/models/discovery.py | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 450d3ed..99a72c5 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -6,9 +6,8 @@ History ------------------ * Added ``json_string_indexes`` to ``FileDiscoveryLocatorResult``: - where a JSON or NDJSON locator passes through a string that holds JSON. - Each number is the index, counted from 0, of a locator segment that held such a string. - It is ``None`` when the locator passes through none, and from a server that predates the field. + the indexes into ``locator``, counted from 0, of the elements whose value is a string that holds JSON. + It is ``None`` when there are none, or when the server predates the field. * Added an optional ``instance`` field to ``DatabaseConnectionConfig``: the SQL Server named instance, taken from the Instance input in the connection form's advanced settings. It round-trips through ``list_connections`` and ``create_or_update_connection``, diff --git a/datamasque/client/models/discovery.py b/datamasque/client/models/discovery.py index 516560c..a2a5c21 100644 --- a/datamasque/client/models/discovery.py +++ b/datamasque/client/models/discovery.py @@ -476,9 +476,8 @@ class FileDiscoveryLocatorResult(BaseModel): data_types: list[str] safe_data_preview: Optional[SafeDataPreview] = None value_count: Optional[int] = None - # The indexes, counted from 0, of the `locator` segments that held a string that holds JSON; - # the segments after each one are the path inside it. - # None when the locator passes through no such string, and from a server that predates the field. + # Indexes into `locator`, counted from 0, of the elements whose value is a string that holds JSON. + # None when there are none, or when the server predates the field. json_string_indexes: Optional[list[int]] = None From d065b8956511ad0e9d97720068aeb951a8e1b7ac Mon Sep 17 00:00:00 2001 From: Timotius Date: Sat, 28 Nov 2026 23:01:14 +1300 Subject: [PATCH 5/6] docs: DM-4104 Call it serialized JSON in the field comment --- datamasque/client/models/discovery.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datamasque/client/models/discovery.py b/datamasque/client/models/discovery.py index a2a5c21..4bafbfc 100644 --- a/datamasque/client/models/discovery.py +++ b/datamasque/client/models/discovery.py @@ -476,7 +476,7 @@ class FileDiscoveryLocatorResult(BaseModel): data_types: list[str] safe_data_preview: Optional[SafeDataPreview] = None value_count: Optional[int] = None - # Indexes into `locator`, counted from 0, of the elements whose value is a string that holds JSON. + # Indexes into `locator`, counted from 0, of the elements whose value is serialized JSON. # None when there are none, or when the server predates the field. json_string_indexes: Optional[list[int]] = None From 8b10765e9e66a04963b85295cc2e87e35db3d1ff Mon Sep 17 00:00:00 2001 From: Timotius Date: Sat, 28 Nov 2026 23:01:23 +1300 Subject: [PATCH 6/6] docs: DM-4104 Call it serialized JSON in the changelog --- HISTORY.rst | 2 +- tests/test_discovery.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 99a72c5..a6c4f16 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -6,7 +6,7 @@ History ------------------ * Added ``json_string_indexes`` to ``FileDiscoveryLocatorResult``: - the indexes into ``locator``, counted from 0, of the elements whose value is a string that holds JSON. + the indexes into ``locator``, counted from 0, of the elements whose value is serialized JSON. It is ``None`` when there are none, or when the server predates the field. * Added an optional ``instance`` field to ``DatabaseConnectionConfig``: the SQL Server named instance, taken from the Instance input in the connection form's advanced settings. diff --git a/tests/test_discovery.py b/tests/test_discovery.py index 668f4c0..09a4582 100644 --- a/tests/test_discovery.py +++ b/tests/test_discovery.py @@ -1095,7 +1095,7 @@ def test_file_discovery_value_counts_parse(): def test_file_discovery_json_string_indexes_parse(): - """A locator through a string that holds JSON carries its string indexes; one from an older server has none.""" + """A locator through serialized JSON carries its string indexes; one from an older server has none.""" def locator_result(**extra: object) -> dict: return {