Skip to content

fix: fix parent node jump lookup#1252

Merged
devsergiy merged 2 commits intomasterfrom
sergiy/eng-7686-fix-parent-node-jump-lookup
Jul 28, 2025
Merged

fix: fix parent node jump lookup#1252
devsergiy merged 2 commits intomasterfrom
sergiy/eng-7686-fix-parent-node-jump-lookup

Conversation

@devsergiy
Copy link
Copy Markdown
Member

@devsergiy devsergiy commented Jul 28, 2025

Summary by CodeRabbit

  • Bug Fixes
    • Improved the logic for selecting parent nodes, ensuring the traversal continues upward even when skipping certain external parents. This enhances the reliability of parent node selection in complex hierarchies.

Checklist

  • I have discussed my proposed changes in an issue and have received approval to proceed.
  • I have followed the coding standards of the project.
  • Tests or benchmarks have been added or updated.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jul 28, 2025

Walkthrough

The update changes the logic for traversing parent nodes in a node hierarchy. Instead of halting traversal when encountering an external parent node with no current node, the code now skips that parent and continues searching upward. A TODO comment was added regarding potential edge cases with root nodes and entity resolvers.

Changes

Cohort / File(s) Change Summary
Parent Node Traversal Logic
v2/pkg/engine/plan/datasource_filter_visitor.go
Modified parent selection logic to skip external parents without breaking traversal; added a TODO comment about root node edge cases.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~7 minutes

Possibly related PRs

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch sergiy/eng-7686-fix-parent-node-jump-lookup

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 74026ac and 6401a90.

📒 Files selected for processing (1)
  • v2/pkg/engine/plan/datasource_filter_visitor.go (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Build and test (go 1.23 / ubuntu-latest)
  • GitHub Check: Build and test (go 1.23 / windows-latest)
  • GitHub Check: Build and test (go 1.23 / windows-latest)
  • GitHub Check: Build and test (go 1.23 / ubuntu-latest)
🔇 Additional comments (1)
v2/pkg/engine/plan/datasource_filter_visitor.go (1)

257-262: Good improvement to parent traversal logic.

The change from break to continue when encountering an external parent node is a logical improvement. This allows the traversal to skip non-selectable external parents while continuing to search for a valid root node higher in the hierarchy, which aligns better with the method's goal of finding a resolution starting point.

Comment on lines +264 to +267
// TODO: there could be a potential situation when we have selected root node with enabled entity resolver,
// but we can't jump to it because no parent could provide a key for it
// Need to consider how to move this logic into the selection process of duplicated nodes maybe?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Address the TODO regarding unreachable root nodes.

The TODO comment highlights a critical edge case where a root node with an enabled entity resolver might be selected but remain unreachable because no parent can provide the required key. This could lead to invalid query plans.

Please verify if this edge case can occur in practice and consider implementing the suggested integration with the duplicate node selection process. You can run the following script to search for related test cases or similar logic patterns:


🏁 Script executed:

#!/bin/bash
# Search for test cases related to entity resolvers and key provision
echo "Searching for entity resolver tests..."
rg -A 10 -B 5 "entity.*resolver|DisabledEntityResolver" --type go

echo -e "\nSearching for key provision logic..."
rg -A 5 -B 5 "provide.*key|requiresKey" --type go

echo -e "\nSearching for duplicate node selection logic..."
rg -A 10 -B 5 "selectDuplicateNodes|duplicated.*node" --type go

Length of output: 67504


Implement handling for unreachable root nodes with enabled entity resolver

The TODO at v2/pkg/engine/plan/datasource_filter_visitor.go (around lines 264–267)

// TODO: there could be a potential situation when we have selected root node with enabled entity resolver,
// but we can't jump to it because no parent could provide a key for it
// Need to consider how to move this logic into the selection process of duplicated nodes maybe?

remains unaddressed and no existing tests cover a scenario where:

  • a node is marked IsRootNode && !DisabledEntityResolver
  • but its ancestor chain cannot provide the required key path (isSelectedParentCouldProvideKeysForCurrentNode fails all the way to the root)
  • causing the planner to select an unreachable entry point

To resolve:

• In selectDuplicateNodes (and/or the initial root-selection stage), filter out any IsRootNode && !DisabledEntityResolver candidates when there is no valid parent-to-child key path.
• Add a new unit test in datasource_filter_visitor that constructs a query plan where a root entity is resolvable but disconnected (no key-providing parent) and asserts it is correctly skipped or replaced by an alternate duplicate with a valid key path.

Fix at:

  • v2/pkg/engine/plan/datasource_filter_visitor.go, method(s) around root-node discovery and in selectDuplicateNodes
  • Add corresponding test in v2/pkg/engine/plan/datasource_filter_visitor_test.go
🤖 Prompt for AI Agents
In v2/pkg/engine/plan/datasource_filter_visitor.go around lines 264 to 267, the
TODO about handling root nodes with enabled entity resolver but no valid parent
key path is unaddressed. Fix this by updating the selectDuplicateNodes function
and/or the root-selection logic to filter out any nodes marked IsRootNode with
DisabledEntityResolver false when no parent can provide the required key path.
Additionally, add a unit test in
v2/pkg/engine/plan/datasource_filter_visitor_test.go that creates a query plan
with such a disconnected root entity and verifies it is skipped or replaced by a
valid duplicate node with a proper key path.

@devsergiy devsergiy merged commit 9fb01be into master Jul 28, 2025
10 checks passed
@devsergiy devsergiy deleted the sergiy/eng-7686-fix-parent-node-jump-lookup branch July 28, 2025 22:57
devsergiy pushed a commit that referenced this pull request Jul 28, 2025
🤖 I have created a release *beep* *boop*
---


##
[2.0.0-rc.213](v2.0.0-rc.212...v2.0.0-rc.213)
(2025-07-28)


### Bug Fixes

* fix parent node jump lookup
([#1252](#1252))
([9fb01be](9fb01be))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Bug Fixes**
  * Resolved an issue with parent node jump lookup.

* **Documentation**
* Added a changelog entry for version 2.0.0-rc.213, detailing the latest
bug fix.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@coderabbitai coderabbitai Bot mentioned this pull request Oct 24, 2025
3 tasks
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