Add details about validation target when reporting validation errors in read mode (warnings)#844
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #844 +/- ##
==========================================
+ Coverage 95.29% 95.30% +0.01%
==========================================
Files 218 219 +1
Lines 7671 7696 +25
==========================================
+ Hits 7310 7335 +25
Misses 361 361 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This was referenced Jul 1, 2026
bendichter
approved these changes
Jul 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Background
io.createParsedTypeis responsible for creating neurodata objects when reading NWB files. It currently catches all exceptions on read to enrich the error message with what neurodata type and what file location the validation fails for, in order to support troubleshooting.As part of ongoing work (PR #830) to support lenient read (warn instead of error when data validation fails), we introduced the helper function
reportSchemaViolationin PR #836.Problem
This new function will produce warnings instead of errors for validation failures, but MATLAB does not have any mechanism for catching warnings. If the warning does not carry information about the specific neurodata type and file location, trouble shooting becomes much harder.
Solution
This PR adds a
validationTargetcontext which is set inio.createParsedTypeand carries information about the type and path of the current object being constructed. This context is read in thereportSchemaViolationfunction in order to enrich the warning message with what neurodata type and what file location the warning applies to.Example
Reading a file from Dandiset 000011
nwbRead('sub-255200_ses-20140910_behavior+ecephys+ogen.nwb')Before:
After:
How to test the behavior?
Checklist
fix #XXwhereXXis the issue number?