fix: Issue #27 - list_library_symbols now returns proper error for missing libraries
**Root Cause:** When a library wasn't registered in sym-lib-table, the tool returned: - success: true - symbols: [] - count: 0 This was confusing because it looked like the library existed but was empty. **The Fix:** Now explicitly checks if library exists in sym-lib-table before attempting to list symbols. If not found, returns: - success: false - Clear error message: "Library 'X' not found in sym-lib-table" - Helpful details about how to resolve (add to sym-lib-table or use available libs) - Count of available libraries - Suggestion to use 'list_symbol_libraries' tool **Test Results:** ✓ Non-existent library (BQ25896RTWT): Returns error as expected ✓ Valid library (Device): Returns 533 symbols successfully **User Impact:** Users will now get clear feedback when they try to access libraries that aren't registered in their KiCad configuration, instead of seeing "0 symbols" which suggests the library exists but is empty. Fixes #27 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -529,6 +529,19 @@ class SymbolLibraryCommands:
|
|||||||
"message": "Missing library parameter"
|
"message": "Missing library parameter"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Check if library exists in sym-lib-table
|
||||||
|
if library not in self.library_manager.libraries:
|
||||||
|
available_libs = list(self.library_manager.libraries.keys())
|
||||||
|
return {
|
||||||
|
"success": False,
|
||||||
|
"message": f"Library '{library}' not found in sym-lib-table",
|
||||||
|
"errorDetails": f"Library '{library}' is not registered in your KiCad symbol library table. "
|
||||||
|
f"Found {len(available_libs)} libraries. "
|
||||||
|
f"Please add this library to your sym-lib-table file, or use one of the available libraries.",
|
||||||
|
"available_libraries_count": len(available_libs),
|
||||||
|
"suggestion": "Use 'list_symbol_libraries' to see all available libraries"
|
||||||
|
}
|
||||||
|
|
||||||
symbols = self.library_manager.list_symbols(library)
|
symbols = self.library_manager.list_symbols(library)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user