-
Notifications
You must be signed in to change notification settings - Fork 449
Fix zombie linkIds on node deletion, add safety check #7153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add defensive checks to prevent potential runtime errors.
The logic correctly clears stale linkIds for subgraph outputs, but lacks validation that could cause crashes in edge cases.
Apply this diff to add defensive checks:
The optional chaining prevents crashes if:
outputNodeis undefinedslotsarray is undefinedtarget_slotindex is out of boundslinkIdsarray doesn't exist📝 Committable suggestion
🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given how often we accidentally try to dereference undefined values, I agree with the robot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DrJKL, absolutely, defensive checks are essential here. Here's the improved code with proper guards:
This defensive approach protects against:
outputNodebeing undefined or nullslotsarray not existingtarget_slotindex being out of boundslinkIdsarray not being initializedThe optional chaining (
?.) will short-circuit the evaluation if any property in the chain is nullish, preventing the runtime errors that could occur with direct property access. This is especially important in this cleanup code path where we're dealing with potentially stale or partially-cleaned-up state.🧠 Learnings used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@coderabbitai
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DrJKL, fair enough! 🦆
Hope the defensive checks help prevent those undefined dereference issues. Let me know if you need anything else!
🧠 Learnings used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add a check specifically for the array indexing. I note that the actual bug here was only found because there was a single code section that doesn't silently ignore broken state.
Blindly adding nullchecks for properties that are defined to never be null is actively detrimental to the health of the codebase. It allows that broken state to bleed into other areas and makes it harder to determine the root cause.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we didn't have so many
as anyand// @ts-expect-errors (and maybe more immutable objects...), I'd be much more confident about their non-nullish nature.