Skip to content

Conversation

@ChenZiHong-Gavin
Copy link
Collaborator

No description provided.

@github-actions github-actions bot added the core label Jan 14, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @ChenZiHong-Gavin, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the robustness of edge creation across different graph storage implementations by enforcing stricter validation. It ensures that edges are only established between pre-existing nodes, preventing the creation of orphaned edges or unintended implicit node generation. This change leads to more predictable graph states and improved data integrity within the graph generation process.

Highlights

  • Kuzu Storage Edge Upsertion: Modified the upsert_edge method in kuzu_storage.py to explicitly check for the existence of both source and target nodes. If either node is missing, the edge upsertion is skipped, and a warning message is printed, preventing the previous behavior of implicitly creating missing nodes.
  • NetworkX Storage Edge Upsertion: Introduced a new check in the upsert_edge method of networkx_storage.py to ensure that both the source and target nodes exist in the graph before attempting to add an edge. If any node is not found, the edge creation is aborted, and a warning is logged.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request changes the behavior of upsert_edge in both KuzuStorage and NetworkXStorage. Instead of creating nodes if they don't exist when an edge is being upserted, the new implementation skips the edge upsert operation if either the source or target node is missing. This change is consistent with the pull request's title and is applied uniformly across both storage backends.

My main feedback is regarding the use of print() to report that the edge upsert is being skipped. While this is consistent with other parts of the codebase, using the logging module would be a better practice for library code, as it provides more flexibility for consumers to handle log messages. I've left specific comments on this.

Comment on lines +348 to +350
print(
f"Cannot upsert edge {source_node_id}->{target_node_id} as one or both nodes do not exist."
)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Using print() for logging is generally discouraged in library code because it's not configurable by the application using the library. It's better to use the logging module. This allows consumers to control log levels, format, and output destinations.

I suggest using logging.warning here. This also uses the recommended practice of passing arguments to logging methods to defer string formatting.

Note: You will need to add import logging at the top of the file.

Suggested change
print(
f"Cannot upsert edge {source_node_id}->{target_node_id} as one or both nodes do not exist."
)
logging.warning(
"Cannot upsert edge %s->%s as one or both nodes do not exist.",
source_node_id,
target_node_id,
)

Comment on lines +163 to +165
print(
f"Cannot upsert edge {source_node_id} -> {target_node_id} because one or both nodes do not exist."
)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

As with the other storage implementation, using print() for logging is not ideal. Using the logging module provides better control for consumers of this library.

I suggest using logging.warning here. This also uses the recommended practice of passing arguments to logging methods to defer string formatting.

Note: You will need to add import logging at the top of the file.

Suggested change
print(
f"Cannot upsert edge {source_node_id} -> {target_node_id} because one or both nodes do not exist."
)
logging.warning(
"Cannot upsert edge %s -> %s because one or both nodes do not exist.",
source_node_id,
target_node_id,
)

@ChenZiHong-Gavin ChenZiHong-Gavin merged commit 02dcafe into main Jan 14, 2026
9 checks passed
@ChenZiHong-Gavin ChenZiHong-Gavin deleted the fix/fix-graph-storage branch January 14, 2026 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants