UnicodeDecodeError on Windows when running restaurant_finder sample due to default GBK encoding
#1451 aperta il 18 mag 2026
Metriche repository
- Star
- (15.202 star)
- Metriche merge PR
- (Metriche PR in attesa)
Descrizione
Description
When running the restaurant_finder sample on Windows, the agent fails when reading the restaurant data file.
The issue appears to be caused by Python using the system default encoding on Windows. On a Chinese Windows environment, the default encoding is gbk, but the data file seems to be encoded as UTF-8.
As a result, the sample crashes with a UnicodeDecodeError.
Environment
- OS: Windows
- Shell: PowerShell
- Project path:
samples/agent/adk/restaurant_finder - Python environment: created by
uv - Sample: A2UI restaurant finder demo
Steps to Reproduce
- Start the restaurant finder agent:
cd samples/agent/adk/restaurant_finder
uv run .
- Start the Lit client shell:
cd samples/client/lit/shell
npm run dev
- Open the demo in the browser and send a restaurant-related prompt.
Actual Behavior实际行为
The agent crashes with the following error:
UnicodeDecodeError: 'gbk' codec can't decode byte 0x86 in position 198: illegal multibyte sequence
Full relevant traceback:
File "samples/agent/adk/restaurant_finder/tools.py", line 40, in get_restaurants
restaurant_data_str = f.read()
UnicodeDecodeError: 'gbk' codec can't decode byte 0x86 in position 198: illegal multibyte sequence
Possible Cause
In samples/agent/adk/restaurant_finder/tools.py, the file is opened without specifying an encoding:
with open(...) as f:
restaurant_data_str = f.read()
Suggested Fix
Specify UTF-8 explicitly when reading the data file:
with open(..., "r", encoding="utf-8") as f:
restaurant_data_str = f.read()