Skip to content

Handle bare dict depends_on from MATLAB jsonencode#20

Merged
stevevanhooser merged 2 commits intomainfrom
claude/fix-serialize-depends-on-vlBwk
Mar 22, 2026
Merged

Handle bare dict depends_on from MATLAB jsonencode#20
stevevanhooser merged 2 commits intomainfrom
claude/fix-serialize-depends-on-vlBwk

Conversation

@stevevanhooser
Copy link
Copy Markdown
Contributor

Summary

Fix handling of depends_on field when MATLAB's jsonencode converts single-element cell arrays to scalar dictionaries instead of arrays.

Changes

  • Added normalization logic in _serialize_depends_on() to convert a bare dict depends_on to a single-element list before processing
  • Added normalization logic in doc_to_sql() to normalize depends_on at the document properties level before building SQL tables
  • This ensures consistent handling regardless of whether depends_on arrives as a dict or list from MATLAB-generated JSON

Details

MATLAB's jsonencode function converts single-element cell arrays to scalar values in JSON. When depends_on contains 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

claude added 2 commits March 22, 2026 19:08
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
@stevevanhooser stevevanhooser merged commit fa5698b into main Mar 22, 2026
5 checks passed
@stevevanhooser stevevanhooser deleted the claude/fix-serialize-depends-on-vlBwk branch March 22, 2026 19:17
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.

2 participants