Proposal summary
The IsJson heuristic metric (sdks/python/src/opik/evaluation/metrics/heuristics/is_json.py)
currently has no dedicated unit test coverage. Searching the test suite for IsJson /
is_json_metric returns no matches.
I'd like to add a dedicated test file, sdks/python/tests/unit/evaluation/metrics/test_is_json.py,
covering:
- Valid JSON inputs (object, array, and primitive types like
"5", "null", "true",
which are valid per json.loads but easy to overlook)
- Invalid JSON inputs (malformed JSON, empty string)
- Non-string inputs (
None, int) — currently silently caught by the metric's blanket
except Exception and scored 0.0, with no distinction from genuinely malformed JSON
This follows the same testing pattern already used for other heuristic metrics in
test_heuristics.py / test_sentiment.py (instantiate with track=False, assert against
the full ScoreResult object).
Motivation
What problem are you trying to solve?
IsJson is publicly exported (opik.evaluation.metrics.IsJson) and commonly used to
validate LLM output in structured extraction / tool-calling eval pipelines. Without tests,
its edge-case behavior is undocumented and unverified.
How are you currently solving this problem?
N/A — there is currently no test coverage for this metric at all.
What are the benefits of this feature?
Documents and locks in the expected behavior for edge cases (JSON primitives, malformed
input, non-string input), preventing silent regressions and clarifying current behavior
for future contributors.
I'm a first-time contributor and would like to open a PR for this if it's a welcome addition.
Proposal summary
The
IsJsonheuristic metric (sdks/python/src/opik/evaluation/metrics/heuristics/is_json.py)currently has no dedicated unit test coverage. Searching the test suite for
IsJson/is_json_metricreturns no matches.I'd like to add a dedicated test file,
sdks/python/tests/unit/evaluation/metrics/test_is_json.py,covering:
"5","null","true",which are valid per
json.loadsbut easy to overlook)None,int) — currently silently caught by the metric's blanketexcept Exceptionand scored 0.0, with no distinction from genuinely malformed JSONThis follows the same testing pattern already used for other heuristic metrics in
test_heuristics.py/test_sentiment.py(instantiate withtrack=False, assert againstthe full
ScoreResultobject).Motivation
What problem are you trying to solve?
IsJsonis publicly exported (opik.evaluation.metrics.IsJson) and commonly used tovalidate LLM output in structured extraction / tool-calling eval pipelines. Without tests,
its edge-case behavior is undocumented and unverified.
How are you currently solving this problem?
N/A — there is currently no test coverage for this metric at all.
What are the benefits of this feature?
Documents and locks in the expected behavior for edge cases (JSON primitives, malformed
input, non-string input), preventing silent regressions and clarifying current behavior
for future contributors.
I'm a first-time contributor and would like to open a PR for this if it's a welcome addition.