Skip to content

Commit 66c2939

Browse files
Reject empty string paths in file utility
Co-authored-by: Shri Sukhani <shrisukhani@users.noreply.github.com>
1 parent f71b71c commit 66c2939

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

hyperbrowser/client/file_utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ def ensure_existing_file_path(
2020
) from exc
2121
if not isinstance(normalized_path, str):
2222
raise HyperbrowserError("file_path must resolve to a string path")
23+
if not normalized_path:
24+
raise HyperbrowserError("file_path must not be empty")
2325
if not os.path.exists(normalized_path):
2426
raise HyperbrowserError(missing_file_message)
2527
if not os.path.isfile(normalized_path):

tests/test_file_utils.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,12 @@ def test_ensure_existing_file_path_rejects_non_string_fspath_results():
7070
missing_file_message="missing",
7171
not_file_message="not-file",
7272
)
73+
74+
75+
def test_ensure_existing_file_path_rejects_empty_string_paths():
76+
with pytest.raises(HyperbrowserError, match="file_path must not be empty"):
77+
ensure_existing_file_path(
78+
"",
79+
missing_file_message="missing",
80+
not_file_message="not-file",
81+
)

0 commit comments

Comments
 (0)