Skip to content

fix(embed): convert_paths() drops prefix paths when a longer path shares the same prefix#1220

Open
devteamaegis wants to merge 1 commit into
qdrant:masterfrom
devteamaegis:fix/none-empty-iter-crash
Open

fix(embed): convert_paths() drops prefix paths when a longer path shares the same prefix#1220
devteamaegis wants to merge 1 commit into
qdrant:masterfrom
devteamaegis:fix/none-empty-iter-crash

Conversation

@devteamaegis

Copy link
Copy Markdown

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 node b is created as a leaf. When 'a.b.c' is then processed, b is found and c is appended under it, promoting b from a leaf to an interior node. Because nothing recorded that b was a valid endpoint, as_str_list() skips it entirely.

Why it happens

convert_paths never records that an intermediate node was itself a terminal path, so once a node gains children it stops appearing in as_str_list() output.

Fix

Added an is_terminal: bool field to FieldPath (default False). convert_paths now sets is_terminal = True on the final node of every path. as_str_list emits the current path string for interior nodes that are flagged as terminal before recursing into their children.

Test

test_convert_paths_prefix_path_not_dropped calls convert_paths(['a.b', 'a.b.c']) and asserts that both 'a.b' and 'a.b.c' appear in the recovered string list.

Fixes #1219

… 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'.
@netlify

netlify Bot commented May 31, 2026

Copy link
Copy Markdown

Deploy Preview for poetic-froyo-8baba7 ready!

Name Link
🔨 Latest commit 39b313e
🔍 Latest deploy log https://app.netlify.com/projects/poetic-froyo-8baba7/deploys/6a1c82b9121c7d000853e021
😎 Deploy Preview https://deploy-preview-1220--poetic-froyo-8baba7.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai

coderabbitai Bot commented May 31, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d64328b0-3710-455b-83d2-2eb56e935655

📥 Commits

Reviewing files that changed from the base of the PR and between 326adef and 39b313e.

📒 Files selected for processing (2)
  • qdrant_client/embed/utils.py
  • tests/embed_tests/test_utils.py

📝 Walkthrough

Walkthrough

This PR fixes a bug in convert_paths() where shorter paths were silently dropped when longer paths with the same prefix existed. The fix adds an is_terminal boolean field to the FieldPath model to mark nodes as explicit path endpoints. The convert_paths() function sets is_terminal = True for each node that corresponds to an input string path. The as_str_list() method now only includes paths when the node is marked terminal, preserving prefix paths that would otherwise be treated as interior nodes. A test verifies that both 'a.b' and 'a.b.c' are preserved when both are present.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main bug being fixed: convert_paths() dropping prefix paths when longer paths with the same prefix exist.
Description check ✅ Passed The description comprehensively explains the problem, root cause, and solution with clear examples and directly references the related issue #1219.
Linked Issues check ✅ Passed The PR fully addresses issue #1219 by implementing the is_terminal field on FieldPath, updating convert_paths() to mark terminal nodes, and adding a test case that validates both prefix and longer paths are preserved.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the convert_paths() bug: the is_terminal field addition, the convert_paths() logic update, and the test case are all necessary to resolve issue #1219.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

BUG: convert_paths() silently drops shorter path when a longer path with the same prefix is present

1 participant