@@ -100,6 +100,29 @@ def test_normalize_upload_file_input_rejects_control_character_paths_before_mess
100100 assert exc_info .value .original_error is None
101101
102102
103+ def test_normalize_upload_file_input_uses_metadata_missing_prefix (
104+ monkeypatch : pytest .MonkeyPatch ,
105+ ):
106+ monkeypatch .setattr (
107+ session_upload_utils ,
108+ "SESSION_OPERATION_METADATA" ,
109+ type (
110+ "_Metadata" ,
111+ (),
112+ {
113+ "upload_missing_file_message_prefix" : "Custom missing prefix" ,
114+ "upload_not_file_message_prefix" : "Custom not-file prefix" ,
115+ "upload_open_file_error_prefix" : "Custom open prefix" ,
116+ },
117+ )(),
118+ )
119+
120+ with pytest .raises (HyperbrowserError , match = "Custom missing prefix:" ) as exc_info :
121+ normalize_upload_file_input ("/tmp/nonexistent-upload-prefix-test.txt" )
122+
123+ assert exc_info .value .original_error is None
124+
125+
103126def test_normalize_upload_file_input_returns_open_file_like_object ():
104127 file_obj = io .BytesIO (b"content" )
105128
@@ -202,6 +225,19 @@ def _open_binary_file_stub(file_path, *, open_error_message): # type: ignore[no
202225 "normalize_upload_file_input" ,
203226 lambda file_input : ("bad\t path.txt" , None ),
204227 )
228+ monkeypatch .setattr (
229+ session_upload_utils ,
230+ "SESSION_OPERATION_METADATA" ,
231+ type (
232+ "_Metadata" ,
233+ (),
234+ {
235+ "upload_missing_file_message_prefix" : "Custom missing prefix" ,
236+ "upload_not_file_message_prefix" : "Custom not-file prefix" ,
237+ "upload_open_file_error_prefix" : "Custom open prefix" ,
238+ },
239+ )(),
240+ )
205241 monkeypatch .setattr (
206242 session_upload_utils ,
207243 "open_binary_file" ,
@@ -212,10 +248,7 @@ def _open_binary_file_stub(file_path, *, open_error_message): # type: ignore[no
212248 assert files ["file" ].read () == b"content"
213249
214250 assert captured ["file_path" ] == "bad\t path.txt"
215- assert (
216- captured ["open_error_message" ]
217- == "Failed to open upload file at path: bad?path.txt"
218- )
251+ assert captured ["open_error_message" ] == "Custom open prefix: bad?path.txt"
219252
220253
221254def test_open_upload_files_from_input_rejects_missing_normalized_file_object (
0 commit comments