Skip to content

fix: get_subgraphs prefix matching with shared node name prefixes#7240

Open
r266-tech wants to merge 1 commit intolangchain-ai:mainfrom
r266-tech:fix-get-subgraphs-prefix
Open

fix: get_subgraphs prefix matching with shared node name prefixes#7240
r266-tech wants to merge 1 commit intolangchain-ai:mainfrom
r266-tech:fix-get-subgraphs-prefix

Conversation

@r266-tech
Copy link
Copy Markdown

Summary

Fixes a bug in Pregel.get_subgraphs() where nodes sharing a common name prefix cause incorrect namespace resolution.

Problem

When looking up namespace common_prefix_2|child_subgraph, the startswith check incorrectly matches node common_prefix, corrupting the namespace.

Root Cause

The prefix filter used namespace.startswith(name) without checking the separator boundary.

Fix

Changed the filter to verify the full segment boundary.

Closes #6924

Fixes a bug where get_subgraphs() would fail when two sibling nodes
share a common name prefix (e.g. 'common_prefix' and 'common_prefix_2').

The root cause was using startswith() without checking the namespace
separator boundary. When looking up namespace 'common_prefix_2|x',
the node 'common_prefix' would incorrectly match (since the string
'common_prefix_2|x' starts with 'common_prefix'), then the namespace
would be corrupted by stripping 'common_prefix|' from it, leaving
'2|x' which matches nothing.

Fix: check that the match includes the full segment boundary by
verifying namespace == name or namespace.startswith(name + NS_SEP).

Fixes langchain-ai#6924
@github-actions
Copy link
Copy Markdown
Contributor

This PR has been automatically closed because you are not assigned to the linked issue.

External contributors must be assigned to an issue before opening a PR for it. Please:

  1. Comment on the linked issue to request assignment from a maintainer
  2. Once assigned, edit your PR description and the PR will be reopened automatically

Maintainers: reopen this PR or remove the missing-issue-link label to bypass this check.

@github-actions github-actions Bot closed this Mar 24, 2026
@mdrxy Mason Daugherty (mdrxy) added bypass-issue-check Maintainer override: skip issue-link enforcement and removed missing-issue-link labels Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bypass-issue-check Maintainer override: skip issue-link enforcement external

Projects

None yet

Development

Successfully merging this pull request may close these issues.

get_subgraph fails when nodes share a common prefix

3 participants