Skip to content

fix: add null checks in ToolRegistry to handle re-export barrels#27512

Open
realcarsonterry wants to merge 1 commit into
anomalyco:devfrom
realcarsonterry:fix/tool-registry-null-check
Open

fix: add null checks in ToolRegistry to handle re-export barrels#27512
realcarsonterry wants to merge 1 commit into
anomalyco:devfrom
realcarsonterry:fix/tool-registry-null-check

Conversation

@realcarsonterry
Copy link
Copy Markdown

@realcarsonterry realcarsonterry commented May 14, 2026

Issue for this PR

Closes #27456

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

The ToolRegistry.state() function was crashing with TypeError: Object.entries requires that input parameter not be null or undefined when tool files used re-export syntax like export { tool1 } from "./other".

The issue occurred because:

  1. Object.entries() was called on imported modules without checking if they were valid objects
  2. Exported items weren't validated to be actual tool definitions before processing

The fix adds two defensive checks:

  1. Module validation: Skip modules that are null, undefined, or not objects
  2. Export validation: Skip exports that don't have the required execute function property

This 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?

  1. Reviewed the error stack trace showing Object.entries being called on null/undefined
  2. Identified the exact location in registry.ts line 198 where the unsafe call occurs
  3. Added null checks and function property validation to filter out non-tool exports
  4. The fix follows defensive programming patterns used elsewhere in the codebase

Screenshots / recordings

N/A - This is a null safety fix

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

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
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels May 14, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant