fix: add null checks in ToolRegistry to handle re-export barrels#27512
Open
realcarsonterry wants to merge 1 commit into
Open
fix: add null checks in ToolRegistry to handle re-export barrels#27512realcarsonterry wants to merge 1 commit into
realcarsonterry wants to merge 1 commit into
Conversation
The ToolRegistry.state() function was calling Object.entries() on imported
tool modules without checking if the module or its exports were valid tool
definitions. This caused crashes when tool files used re-export syntax like
`export { tool1, tool2 } from "./other-module"`.
Added two defensive checks:
1. Skip modules that are null, undefined, or not objects
2. Skip exports that don't have the required `execute` function property
This allows tool files to safely use re-export barrels and helper functions
without crashing the tool registry during initialization.
Fixes anomalyco#27456
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Issue for this PR
Closes #27456
Type of change
What does this PR do?
The
ToolRegistry.state()function was crashing withTypeError: Object.entries requires that input parameter not be null or undefinedwhen tool files used re-export syntax likeexport { tool1 } from "./other".The issue occurred because:
Object.entries()was called on imported modules without checking if they were valid objectsThe fix adds two defensive checks:
executefunction propertyThis allows tool files to safely use re-export barrels, helper functions, and type exports without crashing the tool registry during initialization.
How did you verify your code works?
Object.entriesbeing called on null/undefinedregistry.tsline 198 where the unsafe call occursScreenshots / recordings
N/A - This is a null safety fix
Checklist