Skip to content

Fix validation plugin converting characters to Unicode escape sequences (CMEM-8068) - #6

Merged
msaipraneeth merged 3 commits into
mainfrom
bugfix/UnicodeEscape-CMEM-8068
Sep 8, 2026
Merged

Fix validation plugin converting characters to Unicode escape sequences (CMEM-8068)#6
msaipraneeth merged 3 commits into
mainfrom
bugfix/UnicodeEscape-CMEM-8068

Conversation

@msaipraneeth

@msaipraneeth msaipraneeth commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Summary

  • json.dumps() defaults to ensure_ascii=True, which silently escaped non-ASCII characters (e.g. ö) into \uXXXX sequences when the Validate Entities task wrote valid JSON objects to the target JSON dataset.
  • Added ensure_ascii=False so the JSON representation of the original content is preserved.
  • Also fixed test_source_and_target_dataset, which exercises this exact code path: it was never collected by pytest because its name didn't start with test_ (validate_test_... instead of test_...), and it had no @needs_cmem marker unlike its siblings.
  • Corrected and clarified the Validate Entities and Validate Knowledge Graph plugin documentation and parameter descriptions (e.g. fail_on_violations claimed the task fails on the first violation, when it actually validates everything before failing the report; several boolean parameters in validate_graph had no description at all).

Test plan

  • Added test_target_dataset_keeps_unicode_characters, an isolated unit test using a fake Client (via monkeypatch) so it runs without a Corporate Memory connection; confirmed it fails against the pre-fix code with the exact ö escape, then passes with the fix.
  • ruff check and mypy -p tests -p cmem_plugin_validation (package + tests) pass.
  • Full pytest run: all tests that don't require a live CMEM connection pass.

json.dumps() defaults to ensure_ascii=True, which escaped non-ASCII
characters (e.g. ö) into unicode escape sequences when valid JSON
objects were written to the target JSON dataset.

Also fixed test_source_and_target_dataset, which exercises this exact
code path: it was never collected by pytest because its name didn't
start with test_ (validate_test_... instead of test_...) and it had
no @needs_cmem marker, unlike its siblings.
@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown

Coverage

Coverage Report
File Stmts Miss Cover Missing
init.py 0 0 100%
validate_entities/init.py 0 0 100%
validate_entities/state.py 10 0 100%
validate_entities/task.py 134 34 75% 192 201 212 223-226 234-235 249 263-264 323 325-326 329-332 335-338 340 342-344 346 351 354-355 357 359-360
validate_graph/init.py 0 0 100%
validate_graph/state.py 22 0 100%
validate_graph/task.py 77 6 92% 210-211 218-219 222 229
TOTAL 243 40 84%  

Tests Skipped Failures Errors Time
9 0 💤 0 ❌ 0 🔥 109.151 ⏱

A fully mocked Client can't exercise the real upload path, so it
wouldn't have caught issues like the io.StringIO/io.BytesIO mismatch
just found in cmem-plugin-graphql's equivalent code. Use a dedicated
non-ASCII fixture dataset and the existing source-dataset test flow
instead, checking the raw target file bytes for escape sequences.
Corrects fail_on_violations descriptions that claimed early termination
on the first violation, when both tasks actually validate everything
before failing the report. Fills in missing descriptions for boolean
parameters in validate_graph, fixes grammar bugs in the validate_entities
choice labels, and rewrites the Input/Output Modes sections to describe
port shape instead of restating the parameters.
@msaipraneeth
msaipraneeth merged commit 91e64f4 into main Sep 8, 2026
2 checks passed
@msaipraneeth
msaipraneeth deleted the bugfix/UnicodeEscape-CMEM-8068 branch September 8, 2026 18:37
msaipraneeth added a commit that referenced this pull request Sep 8, 2026
Merging PR #6 interleaved its Unreleased entries into the already-tagged
[1.3.1] section instead of creating a new [Unreleased] heading, because
the branch diverged before 1.3.1 was cut and git's line-based merge
couldn't tell the two apart. Splits them back into a proper [Unreleased]
section ahead of the published 1.3.1 entry.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant