Skip to content

Commit 39e44c3

Browse files
committed
Better error message for binary files used with 'config'
1 parent bda41d5 commit 39e44c3

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

riptide/config/service/config_files.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,15 @@ def process_config(
5858
read_file_partial = partial(read_file, config["$source"])
5959
read_file_partial.__name__ = read_file.__name__ # type: ignore
6060

61-
with open(config["$source"]) as stream:
62-
processed_file = service.process_vars_for(stream.read(), [read_file_partial])
61+
with open(config["$source"], encoding="utf-8") as stream:
62+
try:
63+
processed_file = service.process_vars_for(stream.read(), [read_file_partial])
64+
except UnicodeDecodeError as ex:
65+
raise ValueError(
66+
f"Configuration file {config['$source']}, specified by {config['from']} in service {service['$name']} "
67+
f"is not a valid UTF-8 encoded text files. `config' files must be valid UTF-8 encoded text files. "
68+
f"For other files consider using `additional_volumes`."
69+
) from ex
6370

6471
if is_in_source_path:
6572
notice_file = target_file + ".riptide_info.txt"

0 commit comments

Comments
 (0)