generated from canonical/starbase
-
Notifications
You must be signed in to change notification settings - Fork 19
Open
Labels
Description
Bug Description
If you encode testcraft.yaml in utf-32, it gets:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
We should handle that more nicely.
To Reproduce
cp testcraft.yaml testcraft.yaml.bak
iconv -f UTF-8 -t UTF-32 testcraft.yaml.bak > testcraft.yaml
python -m testcraft pack
part yaml
n/aRelevant log output
e
2025-10-15 14:49:39.953 Project file found at /home/lengau/Work/Code/craft-application/testcraft.yaml
2025-10-15 14:49:39.953 Loading project file '/home/lengau/Work/Code/craft-application/testcraft.yaml
2025-10-15 14:49:39.954 testcraft internal error: UnicodeDecodeError('utf-8', b'\xff\xfe\x00\x00n\x00\x00\x00a\x00\x00\x00m\x00\x00\x00e\x00\x00\x00:\x00\x00\x00 \x00\x00\x00c\x00\x00\x00r\x00\x00\x00a\x00\x00\x00f\x00\x00\x00t\x00\x00\x00-\x00\x00\x00a\x00\x00\x00p\x00\x00\x00p\x00\x00\x00l\x00\x00\x00i\x00\x00\x00c\x00\x00\x00a\x00\x00\x00t\x00\x00\x00i\x00\x00\x00o\x00\x00\x00n\x00\x00\x00\n\x00\x00\x00v\x00\x00\x00e\x00\x00\x00r\x00\x00\x00s\x00\x00\x00i\x00\x00\x00o\x00\x00\x00n\x00\x00\x00:\x00\x00\x00 \x00\x00\x00"\x00\x00\x000\x00\x00\x00.\x00\x00\x001\x00\x00\x00"\x00\x00\x00\n\x00\x00\x00\n\x00\x00\x00b\x00\x00\x00a\x00\x00\x00s\x00\x00\x00e\x00\x00\x00:\x00\x00\x00 \x00\x00\x00u\x00\x00\x00b\x00\x00\x00u\x00\x00\x00n\x00\x00\x00t\x00\x00\x00u\x00\x00\x00@\x00\x00\x002\x00\x00\x005\x00\x00\x00.\x00\x00\x001\x00\x00\x000\x00\x00\x00\n\x00\x00\x00p\x00\x00\x00l\x00\x00\x00a\x00\x00\x00t\x00\x00\x00f\x00\x00\x00o\x00\x00\x00r\x00\x00\x00m\x00\x00\x00s\x00\x00\x00:\x00\x00\x00\n\x00\x00\x00 \x00\x00\x00 \x00\x00\x00"\x00\x00\x00*\x00\x00\x00*\x00\x00\x00"\x00\x00\x00:\x00\x00\x00\n\x00\x00\x00 \x00\x00\x00 \x00\x00\x00 \x00\x00\x00 \x00\x00\x00b\x00\x00\x00u\x00\x00\x00i\x00\x00\x00l\x00\x00\x00d\x00\x00\x00-\x00\x00\x00o\x00\x00\x00n\x00\x00\x00:\x00\x00\x00 \x00\x00\x00[\x00\x00\x00a\x00\x00\x00m\x00\x00\x00d\x00\x00\x006\x00\x00\x004\x00\x00\x00,\x00\x00\x00 \x00\x00\x00a\x00\x00\x00r\x00\x00\x00m\x00\x00\x006\x00\x00\x004\x00\x00\x00,\x00\x00\x00 \x00\x00\x00p\x00\x00\x00p\x00\x00\x00c\x00\x00\x006\x00\x00\x004\x00\x00\x00e\x00\x00\x00l\x00\x00\x00,\x00\x00\x00 \x00\x00\x00s\x00\x00\x003\x00\x00\x009\x00\x00\x000\x00\x00\x00x\x00\x00\x00,\x00\x00\x00 \x00\x00\x00r\x00\x00\x00i\x00\x00\x00s\x00\x00\x00c\x00\x00\x00v\x00\x00\x006\x00\x00\x004\x00\x00\x00]\x00\x00\x00\n\x00\x00\x00 \x00\x00\x00 \x00\x00\x00 \x00\x00\x00 \x00\x00\x00b\x00\x00\x00u\x00\x00\x00i\x00\x00\x00l\x00\x00\x00d\x00\x00\x00-\x00\x00\x00f\x00\x00\x00o\x00\x00\x00r\x00\x00\x00:\x00\x00\x00 \x00\x00\x00[\x00\x00\x00a\x00\x00\x00l\x00\x00\x00l\x00\x00\x00]\x00\x00\x00\n\x00\x00\x00\n\x00\x00\x00p\x00\x00\x00a\x00\x00\x00r\x00\x00\x00t\x00\x00\x00s\x00\x00\x00:\x00\x00\x00\n\x00\x00\x00 \x00\x00\x00 \x00\x00\x00m\x00\x00\x00y\x00\x00\x00-\x00\x00\x00t\x00\x00\x00e\x00\x00\x00s\x00\x00\x00t\x00\x00\x00:\x00\x00\x00\n\x00\x00\x00 \x00\x00\x00 \x00\x00\x00 \x00\x00\x00 \x00\x00\x00p\x00\x00\x00l\x00\x00\x00u\x00\x00\x00g\x00\x00\x00i\x00\x00\x00n\x00\x00\x00:\x00\x00\x00 \x00\x00\x00n\x00\x00\x00i\x00\x00\x00l\x00\x00\x00\n\x00\x00\x00', 0, 1, 'invalid start byte')
2025-10-15 14:49:39.955 Traceback (most recent call last):
2025-10-15 14:49:39.955 File "/home/lengau/Work/Code/craft-application/craft_application/application.py", line 669, in run
2025-10-15 14:49:39.955 return_code = self._run_inner()
2025-10-15 14:49:39.955 ^^^^^^^^^^^^^^^^^
2025-10-15 14:49:39.955 File "/home/lengau/Work/Code/craft-application/craft_application/application.py", line 636, in _run_inner
2025-10-15 14:49:39.955 project_service.configure(platform=platform, build_for=build_for)
2025-10-15 14:49:39.955 File "/home/lengau/Work/Code/craft-application/craft_application/services/project.py", line 83, in configure
2025-10-15 14:49:39.955 platforms = self.get_platforms()
2025-10-15 14:49:39.955 ^^^^^^^^^^^^^^^^^^^^
2025-10-15 14:49:39.955 File "/home/lengau/Work/Code/craft-application/craft_application/services/project.py", line 274, in get_platforms
2025-10-15 14:49:39.955 raw_project = self.get_raw()
2025-10-15 14:49:39.955 ^^^^^^^^^^^^^^
2025-10-15 14:49:39.955 File "/home/lengau/Work/Code/craft-application/craft_application/services/project.py", line 201, in get_raw
2025-10-15 14:49:39.955 return copy.deepcopy(self._load_raw_project())
2025-10-15 14:49:39.955 ^^^^^^^^^^^^^^^^^^^^^^^^
2025-10-15 14:49:39.955 File "/home/lengau/Work/Code/craft-application/craft_application/services/project.py", line 192, in _load_raw_project
2025-10-15 14:49:39.955 raw_yaml = util.safe_yaml_load(project_file)
2025-10-15 14:49:39.955 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-10-15 14:49:39.955 File "/home/lengau/Work/Code/craft-application/craft_application/util/yaml.py", line 110, in safe_yaml_load
2025-10-15 14:49:39.955 return yaml.load(stream, Loader=_SafeYamlLoader) # noqa: S506
2025-10-15 14:49:39.955 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-10-15 14:49:39.955 File "/home/lengau/Work/Code/craft-application/.venv/lib/python3.12/site-packages/yaml/__init__.py", line 79, in load
2025-10-15 14:49:39.955 loader = Loader(stream)
2025-10-15 14:49:39.955 ^^^^^^^^^^^^^^
2025-10-15 14:49:39.955 File "/home/lengau/Work/Code/craft-application/craft_application/util/yaml.py", line 94, in __init__
2025-10-15 14:49:39.955 super().__init__(stream)
2025-10-15 14:49:39.955 File "/home/lengau/Work/Code/craft-application/.venv/lib/python3.12/site-packages/yaml/loader.py", line 34, in __init__
2025-10-15 14:49:39.955 Reader.__init__(self, stream)
2025-10-15 14:49:39.956 File "/home/lengau/Work/Code/craft-application/.venv/lib/python3.12/site-packages/yaml/reader.py", line 85, in __init__
2025-10-15 14:49:39.956 self.determine_encoding()
2025-10-15 14:49:39.956 File "/home/lengau/Work/Code/craft-application/.venv/lib/python3.12/site-packages/yaml/reader.py", line 124, in determine_encoding
2025-10-15 14:49:39.956 self.update_raw()
2025-10-15 14:49:39.956 File "/home/lengau/Work/Code/craft-application/.venv/lib/python3.12/site-packages/yaml/reader.py", line 178, in update_raw
2025-10-15 14:49:39.956 data = self.stream.read(size)
2025-10-15 14:49:39.956 ^^^^^^^^^^^^^^^^^^^^^^
2025-10-15 14:49:39.956 File "<frozen codecs>", line 322, in decode
2025-10-15 14:49:39.956 UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
2025-10-15 14:49:39.956 Full execution log: '/home/lengau/.local/state/testcraft/log/testcraft-20251015-144939.945779.log'