fix(prompts): handle undecodable overrides

This commit is contained in:
chengyongru
2026-07-15 01:19:48 +08:00
committed by chengyongru
parent c1fd76add3
commit 0fd4d0ab29
3 changed files with 27 additions and 2 deletions
+2 -2
View File
@@ -25,7 +25,7 @@ def load_workspace_prompt_override(
Returns the loaded text and its original length. Missing, unreadable, and
empty files return ``(None, 0)`` so callers can fall back to their default.
"""
with suppress(OSError):
with suppress(OSError, UnicodeDecodeError):
text = path.read_text(encoding="utf-8").rstrip()
if text:
original_chars = len(text)
@@ -50,7 +50,7 @@ def initialize_workspace_prompt(path: Path, default_prompt: str) -> bool:
not path.is_file() or bool(path.read_text(encoding="utf-8").strip())
):
return False
except OSError:
except (OSError, UnicodeDecodeError):
return False
path.parent.mkdir(parents=True, exist_ok=True)