Skip to content

Fix common key shapes - #24

Merged
robproject merged 2 commits into
mainfrom
fix_common_key_shapes
Oct 17, 2026
Merged

robproject merged 2 commits into
mainfrom
fix_common_key_shapes

Conversation

@robproject

Copy link
Copy Markdown
Owner

No description provided.

Robert Duncan and others added 2 commits October 16, 2026 23:53
`links` was keyed by `link_to`, which only Workspace links have, so any
DocType with Document Links (link_doctype/link_fieldname) died with
KeyError: 'link_to' and stopped `git diff`. DocType `states` (title,
not state), fixtures without `name`, lists with no unique key and
unhashable values crashed the same way, and Print Format format_data
went through a pf_diff that referenced undefined names.

Each parent now has candidate keys, checked against both lists: the
first field must be set in every dict, and the first candidate that is
unique wins. Workspace links fall back to (label, link_to) for Card
Breaks, DocType links use (link_doctype, link_fieldname,
parent_doctype), permissions add permlevel and if_owner, transitions
are (state, action, next_state[, allowed]). Copies of a repeated known
key are aligned by content. With no key, lists are aligned with
difflib instead of compared by index. Auto-detected keys are now
chosen in a fixed order rather than set order.

Also: format_data is diffed as a parsed list, list/dict type changes
no longer crash, scalar lists tolerate unhashable elements, and an
added key is reported at its own path and line instead of the
previous key's.

Checked against the last 150 JSON commits of nine Frappe apps and 200
each of frappe, erpnext and hrms: no new crashes, 134 fixed, and every
other output change reviewed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Keys, values and labels were interpolated into rich markup unescaped,
so data that looks like a tag was rendered instead of printed: Jinja
such as `itemunitprice[i]` lost its `[i]` (italics), and an unmatched
closing tag such as `[/x]` raised MarkupError and stopped `git diff`.
Everything taken from the JSON is now passed through
rich.markup.escape, in tree and table mode.

Against the previous commit, output is byte-identical on the same
commit history except where the data contains tag-like brackets.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@robproject
robproject merged commit e678403 into main Oct 17, 2026
3 checks passed
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.

1 participant