refactor: read settings directly instead of getattr with a second default

About 85 call sites read a setting as getattr(settings, "NAME", fallback),
each carrying its own copy of the default. Every one of those names is a
field with a default on the model, so the fallback could never apply to
the real settings object; it only masked drift. Two had drifted:

- OPENAI_PROMPT_CACHE_KEY defaults to True on the model but the reader
  fell back to False, and two test stubs relied on that.
- SharePoint's MICROSOFT_AUTHORITY fallback to
  https://login.microsoftonline.com/<tenant> never fired, because the
  attribute always exists (as None), so MSAL got authority=None. The
  connector now derives the tenant authority when the setting is unset,
  as its test always assumed.

Four places read EMBEDDINGS_KEY straight from os.environ, skipping the
"None"/"" normalisation the model applies; they read the setting now.
Test stubs that replaced a module's settings with a SimpleNamespace list
every setting the code under test reads.
This commit is contained in:
arc53-machine committed 2026-09-17 11:14:34 +01:00
1 parent d70644743b
commit f882ef49a7
46 files changed
+111 -113

No files matched your search

+2 -2
View File
@@ -129,7 +129,7 @@ class GitHubLoader(BaseRemote):
def _max_file_bytes(self) -> int:
"""Resolve the per-blob size cap; ``0`` disables it."""
raw = getattr(settings, "GITHUB_INGEST_MAX_FILE_BYTES", None)
raw = settings.GITHUB_INGEST_MAX_FILE_BYTES
if isinstance(raw, bool) or not isinstance(raw, (int, str)):
return 1048576
try:
@@ -139,7 +139,7 @@ class GitHubLoader(BaseRemote):
def _max_workers(self) -> int:
"""Resolve the parallel-fetch width, clamped to a sane range."""
raw = getattr(settings, "GITHUB_INGEST_MAX_WORKERS", None)
raw = settings.GITHUB_INGEST_MAX_WORKERS
if isinstance(raw, bool) or not isinstance(raw, (int, str)):
return 8
try: