fix(embed): convert_paths() drops prefix paths when a longer path shares the same prefix#1220
fix(embed): convert_paths() drops prefix paths when a longer path shares the same prefix#1220devteamaegis wants to merge 1 commit into
Conversation
… shares the same prefix When 'a.b' and 'a.b.c' were both present, node 'b' was silently promoted from a leaf to an interior node and the path 'a.b' was lost. Add an is_terminal flag to FieldPath and mark each path's final node as terminal so as_str_list() emits both 'a.b' and 'a.b.c'.
✅ Deploy Preview for poetic-froyo-8baba7 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR fixes a bug in Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
What's broken
convert_paths(['a.b', 'a.b.c'])returns only['a.b.c']. The path'a.b'is silently discarded. After sorting,'a.b'is processed first and nodebis created as a leaf. When'a.b.c'is then processed,bis found andcis appended under it, promotingbfrom a leaf to an interior node. Because nothing recorded thatbwas a valid endpoint,as_str_list()skips it entirely.Why it happens
convert_pathsnever records that an intermediate node was itself a terminal path, so once a node gains children it stops appearing inas_str_list()output.Fix
Added an
is_terminal: boolfield toFieldPath(defaultFalse).convert_pathsnow setsis_terminal = Trueon the final node of every path.as_str_listemits the current path string for interior nodes that are flagged as terminal before recursing into their children.Test
test_convert_paths_prefix_path_not_droppedcallsconvert_paths(['a.b', 'a.b.c'])and asserts that both'a.b'and'a.b.c'appear in the recovered string list.Fixes #1219