Skip to content

Add opt-in paths for JSON conversion errors - #487

Merged
quinnj merged 2 commits into
masterfrom
investigate/json-error-paths
Oct 2, 2026
Merged

quinnj merged 2 commits into
masterfrom
investigate/json-error-paths

Conversation

@quinnj

@quinnj quinnj commented Sep 26, 2026 •

Copy link
Copy Markdown
Member

Typed conversion errors currently identify the failed operation without locating the value in the input. Add error_context=true to the existing parsing entry points. A failing conversion then throws a qualified JSON.ParseError containing an RFC 6901 JSON Pointer, the value's starting byte, and the original exception and backtrace. Parsing {"counts":[1,"bad"]} into an integer-vector field identifies /counts/1 at byte 14. Fixes #428.

Tracking is opt-in and covers parse, parse!, file/IO inputs and selected LazyValues. Paths use input names, including renamed fields and escaped keys. Conversion hooks still receive their original exceptions and can recover. Diagnostics never replay constructors, hooks or partial mutations. A scoped record and a structural walk on failure recover the path; unrecoverable paths are nothing. Unrelated nested inputs and handled exceptions cannot leave a misleading child path. Configuration and initial lexing errors before conversion retain their existing behavior.

The default entry path keeps diagnostics out of inference and execution, preserving default native compilation and avoiding a second conversion tree for downstream types. Enabled diagnostics have a separate cost and are not claimed to support native compilation. Error recovery materializes pointer-backed keys with String(k), matching current master's removal of the old conversion methods. No exports or dependencies are added.

Validation on final head 7c16fd8:

  • Full suites: 2,565 assertions on Julia 1.13.1 / StructUtils 2.9.2 / Parsers 3.0; 2,560 on minimum Julia 1.10.12 / StructUtils 2.8.4 / Parsers 2.8.8. All 236 permanent context and forwarding checks pass on each.
  • The default and literal-false public entry-point fixture compiles with JuliaC 0.3.10 --trim=safe; its executable passes with JULIA_LOAD_CODEGEN_LIB=0. Enabled diagnostics are outside that claim. Strict documentation and doctests pass with local deployment disabled.
  • All 12 hosted checks are green, including the supported runtime/platform matrix, Parsers 2.8.8 and 3.0, documentation and coverage.

Final-head performance checks use unchanged source snapshots, hashed small/large object and array inputs, identical dependencies, alternating process order and full decoded-value comparisons. Default and literal-false allocations match master on all four fixtures on floor/current Julia. Enabling diagnostics adds 32 bytes per parse in these fixtures. Two floor controls compile both unmodified sources in separate namespaces and rotate execution order: neither replaces existing shared methods, and median paired default/literal-false ratios range from 0.981 to 1.018 on the small-array and large-object fixtures. A fresh six-process floor run with normal package loading gives default ratios from 0.758 to 1.140 as host load varies. Earlier separate-process floor observations were slower under heavier contention; these controls do not reproduce a consistent regression, and neither a speedup nor universal timing parity is claimed. All raw runs are retained in the maintenance evidence.

An earlier Windows floor job exited with an access violation during the JSON test corpus. A paired unchanged-master/final-head run on the same Julia and dependency versions completed all 319 corpus markers and full tests for both sources. The original job's targeted rerun also passed without source changes. The earlier access violation remains unexplained; it is not presented as a fixed source defect.

This change was researched, implemented, independently reviewed and tested by Codex as part of an AI-driven maintenance review.

Co-authored by Codex

@codecov

codecov Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.34711% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.47%. Comparing base (a69c082) to head (7c16fd8).

Files with missing lines Patch % Lines
src/parse.jl 98.21% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #487      +/-   ##
==========================================
+ Coverage   92.09%   92.47%   +0.37%     
==========================================
  Files           7        7              
  Lines        1784     1887     +103     
==========================================
+ Hits         1643     1745     +102     
- Misses        141      142       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

quinnj added 2 commits October 2, 2026 00:10
PtrString exposes its materializing constructor after the current main removed conversion methods. Use that constructor when recovering an error path.
@quinnj
quinnj force-pushed the investigate/json-error-paths branch from 0940554 to 7c16fd8 Compare October 2, 2026 06:23
@quinnj
quinnj merged commit 35fb340 into master Oct 2, 2026
21 of 22 checks passed
@quinnj
quinnj deleted the investigate/json-error-paths branch October 2, 2026 07:52
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.

Improve Error Handling by proving path to error in JSON.

1 participant