fix: narrow bare except Exception to specific types where safe

Replace broad except Exception with specific exception types in 6
sites where the expected failure mode is well-defined:

- normalize.py: OSError for file read, ImportError for optional import
- miner.py: OSError for file read_text
- entity_detector.py: OSError for file read in scan loop
- convo_miner.py: (OSError, ValueError) for normalize which reads
  and parses files
- entity_registry.py: (URLError, OSError, JSONDecodeError, KeyError)
  for Wikipedia lookup fallback

ChromaDB except Exception sites (~30) are left broad for now.
chromadb.errors defines NotFoundError, DuplicateIDError,
InvalidDimensionException etc., but narrowing those sites requires
importing from chromadb.errors and validating across supported
versions (>=0.4.0). MCP server handlers also left broad for
resilience.
This commit is contained in:
adv3nt3
2026-04-07 13:51:27 +02:00
parent 1782628b8a
commit 312d380aab
5 changed files with 6 additions and 6 deletions
+1 -1
View File
@@ -256,7 +256,7 @@ def _wikipedia_lookup(word: str) -> dict:
"note": "not found in Wikipedia — likely a proper noun or unusual name",
}
return {"inferred_type": "unknown", "confidence": 0.0, "wiki_summary": None}
except Exception:
except (urllib.error.URLError, OSError, json.JSONDecodeError, KeyError):
return {"inferred_type": "unknown", "confidence": 0.0, "wiki_summary": None}