Skip to content

Commit 3fbc27f

Browse files
google-genai-botcopybara-github
authored andcommitted
fix: handle UnicodeDecodeError when loading skills in ADK
PiperOrigin-RevId: 869956988
1 parent d56cb41 commit 3fbc27f

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/google/adk/skills/utils.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,15 @@ def _load_dir(directory: pathlib.Path) -> dict[str, str]:
3636
files = {}
3737
if directory.exists() and directory.is_dir():
3838
for file_path in directory.rglob("*"):
39+
if "__pycache__" in file_path.parts:
40+
continue
3941
if file_path.is_file():
4042
relative_path = file_path.relative_to(directory)
41-
files[str(relative_path)] = file_path.read_text(encoding="utf-8")
43+
try:
44+
files[str(relative_path)] = file_path.read_text(encoding="utf-8")
45+
except UnicodeDecodeError:
46+
# Binary files or non-UTF-8 files are skipped for text content.
47+
continue
4248
return files
4349

4450

0 commit comments

Comments
 (0)