Skip to content

Commit 565bb93

Browse files
marcelsafinCopilot
andcommitted
docs: update workaround rationale now that _load handles UnicodeDecodeError
Review follow-up: _sibling_extension_ids and test_non_utf8_registry_does_not_crash documented the pre-fix _load() contract; reword both as defense-in-depth so the rationale stays true. Assisted-by: GitHub Copilot (model: claude-fable-5, autonomous) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 6fff638 commit 565bb93

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

src/specify_cli/extensions/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4259,11 +4259,11 @@ def _sibling_extension_ids(self) -> list[str]:
42594259
Returns an empty list if the registry is missing or corrupted
42604260
(fresh project, ad-hoc test harness) so ``_get_env_config`` degrades
42614261
to its pre-fix behaviour rather than crashing. ``UnicodeError`` is
4262-
caught alongside ``OSError`` because ``ExtensionRegistry._load()``
4263-
opens the file in text mode and only handles ``JSONDecodeError`` /
4264-
``FileNotFoundError``, so a registry file with non-UTF-8 bytes would
4265-
otherwise surface a ``UnicodeDecodeError`` here and break *every*
4266-
config read instead of degrading gracefully.
4262+
caught alongside ``OSError`` as defense in depth:
4263+
``ExtensionRegistry._load()`` now starts fresh on a non-UTF-8
4264+
registry itself, but this scan must degrade gracefully even if that
4265+
contract regresses, because a failure here would break *every*
4266+
config read.
42674267
42684268
Used by ``_get_env_config`` to detect env vars whose remainder claims
42694269
a longer, sibling-owned prefix (e.g. ``SPECKIT_GIT_HOOKS_URL`` is

tests/test_extensions.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10472,10 +10472,10 @@ def test_config_only_leftover_not_treated_as_sibling(self, tmp_path, monkeypatch
1047210472
def test_non_utf8_registry_does_not_crash(self, tmp_path, monkeypatch):
1047310473
"""A registry file with invalid text encoding must NOT propagate
1047410474
``UnicodeDecodeError`` out of the sibling scan and abort every
10475-
config read. ``ExtensionRegistry._load()`` catches ``JSONDecodeError``
10476-
/ ``FileNotFoundError`` only, so ``_sibling_extension_ids`` must
10477-
additionally swallow ``UnicodeError`` and degrade to the documented
10478-
pre-fix behaviour.
10475+
config read. ``ExtensionRegistry._load()`` now starts fresh on a
10476+
non-UTF-8 registry itself, but ``_sibling_extension_ids`` keeps
10477+
swallowing ``UnicodeError`` as defense in depth so a regression of
10478+
that contract still degrades to the documented pre-fix behaviour.
1047910479
"""
1048010480
extensions_dir = tmp_path / ".specify" / "extensions"
1048110481
extensions_dir.mkdir(parents=True)

0 commit comments

Comments
 (0)