Skip to content

Conversation

@devin-ai-integration
Copy link
Contributor

Fix: Add helpful error messages for common tool import typos (Issue #3776)

Summary

This PR addresses issue #3776 where users were getting confusing import errors when trying to import tools from crewai_tools with incorrect capitalization (e.g., PGSearchtool instead of PGSearchTool).

Changes made:

  • Added a module-level __getattr__ function to crewai_tools/__init__.py that intercepts failed attribute access
  • Provides helpful error messages when users mistype tool names with lowercase 't' (e.g., CSVSearchtool → suggests CSVSearchTool)
  • Special handling for PGSearchTool which is documented but not yet implemented - provides clear "under development" message
  • Added comprehensive test suite (test_import_errors.py) with 5 test cases covering typos, non-implemented tools, and non-existent tools

Example error messages:

# Before: AttributeError: module 'crewai_tools' has no attribute 'PGSearchtool'
# After: ImportError: Cannot import name 'PGSearchtool' from 'crewai_tools'. Did you mean 'PGSearchTool'? Note: Tool names use capital 'T' in 'Tool'.

# For PGSearchTool: NotImplementedError: 'PGSearchTool' is currently under development and not yet available. Please check the CrewAI documentation for updates on when this tool will be released.

Review & Testing Checklist for Human

  • Test actual import behavior: Run a Python script that tries from crewai_tools import PGSearchtool and from crewai_tools import PGSearchTool to verify the error messages display correctly in real usage (not just with getattr())
  • Verify PGSearchTool status: Confirm that "under development" is the correct messaging for PGSearchTool, or if it should say something else (deprecated, removed, etc.)
  • Check for regressions: Import a few existing tools (e.g., CSVSearchTool, FileReadTool) to ensure the __getattr__ doesn't interfere with normal imports
  • Consider other tools: Check if there are other documented-but-not-implemented tools that should get similar treatment

Test Plan

# Test script to run manually:
import crewai_tools

# Should work fine
from crewai_tools import CSVSearchTool
print("✓ CSVSearchTool imported successfully")

# Should show helpful typo error
try:
    from crewai_tools import CSVSearchtool
except ImportError as e:
    print(f"✓ Typo caught: {e}")

# Should show "under development" error  
try:
    from crewai_tools import PGSearchTool
except NotImplementedError as e:
    print(f"✓ Not implemented: {e}")

Notes

- Add __getattr__ to crewai_tools/__init__.py to catch common typos
- Provide helpful error message when users try to import tools with lowercase 't' (e.g., PGSearchtool instead of PGSearchTool)
- Add specific error for PGSearchTool indicating it's under development
- Add comprehensive tests to verify error handling

Fixes #3776

Co-Authored-By: João <[email protected]>
@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

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.

1 participant