Handle bare dict depends_on from MATLAB jsonencode#20
Merged
stevevanhooser merged 2 commits intomainfrom Mar 22, 2026
Merged
Conversation
MATLAB's jsonencode converts single-element cell arrays to scalars, so depends_on can arrive as a bare dict instead of a list. Normalize it to a single-element list in both _serialize_depends_on and doc_to_sql for defense in depth. https://claude.ai/code/session_01UbcbwwRqiY8mCMRf2pEsWg
MATLAB's jsonencode converts single-element cell arrays to scalars. This affected multiple code paths beyond _serialize_depends_on: - document.py: Add _normalize_file_info() and _ensure_depends_on_list() helpers. Use them in is_in_file_list, add_file, remove_file, dependency_value, and set_dependency_value. - sqlitedb.py: Extend _matlab_compatible_props to unwrap single-element file_info lists for MATLAB compatibility. - sqlitedb.py: Extend _normalize_loaded_props to re-wrap bare dict file_info back to lists on load. https://claude.ai/code/session_01UbcbwwRqiY8mCMRf2pEsWg
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.
Summary
Fix handling of
depends_onfield when MATLAB'sjsonencodeconverts single-element cell arrays to scalar dictionaries instead of arrays.Changes
_serialize_depends_on()to convert a bare dictdepends_onto a single-element list before processingdoc_to_sql()to normalizedepends_onat the document properties level before building SQL tablesdepends_onarrives as a dict or list from MATLAB-generated JSONDetails
MATLAB's
jsonencodefunction converts single-element cell arrays to scalar values in JSON. Whendepends_oncontains only one element, it gets serialized as a dict rather than an array. These changes normalize the structure to always be a list before further processing, preventing downstream errors in serialization and SQL generation.https://claude.ai/code/session_01UbcbwwRqiY8mCMRf2pEsWg