Skip to content

Commit d335054

Browse files
committed
Check MUX loader file exists and has json ext
1 parent f776bca commit d335054

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

  • crates/common/src/config

crates/common/src/config/mux.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,17 @@ impl MuxConfig {
123123
pub fn loader_env(&self) -> Option<(String, String, String)> {
124124
self.loader.as_ref().and_then(|loader| match loader {
125125
MuxKeysLoader::File(path_buf) => {
126+
if !path_buf.try_exists().is_ok_and(|exists| exists) {
127+
panic!("path doesn't exist: {:?}", path_buf);
128+
}
129+
130+
if !path_buf
131+
.file_name()
132+
.is_some_and(|name| name.to_string_lossy().to_lowercase().ends_with(".json"))
133+
{
134+
panic!("file doesn't have a .json extension");
135+
}
136+
126137
let path =
127138
path_buf.to_str().unwrap_or_else(|| panic!("invalid path: {:?}", path_buf));
128139
let internal_path = get_mux_path(&self.id);

0 commit comments

Comments
 (0)