fix(checks): accept parsed string JSON values#2512
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the JSON validation logic to accept plain strings as valid inputs instead of attempting to parse them as JSON and failing. It introduces a helper method _looks_like_serialized_json to identify if a string is serialized JSON. The reviewer provided critical feedback regarding potential bugs in this helper: whitespace-only strings can bypass the empty string check, and the prefix-matching logic is too loose, which would incorrectly classify plain strings starting with JSON-like prefixes (e.g., "truth", "nullify") as serialized JSON and cause parsing errors. Robust code suggestions were provided to address both issues.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
hey @kevinmessiaen @davidberenstein1957 can someone look into this? |
|
Fixed by #2575 |
Closes #2511
Summary
JsonValidto accept non-empty plain Python strings as already parsed JSON scalar valuesTesting
uv run --no-sync -m pytest -q libs/giskard-checks/tests/builtin/test_json_valid.pyuv run --no-sync ruff check libs/giskard-checks/src/giskard/checks/builtin/json_valid.py libs/giskard-checks/tests/builtin/test_json_valid.pyVerification: 23 passed, ruff passed.