@@ -43,3 +43,47 @@ def test_put_with_https_proxy(conn_cnx, tmp_path, mitm_proxy, monkeypatch):
4343
4444 ls_result = cur .execute (f"LIST @{ stage_name } " ).fetchall ()
4545 assert len (ls_result ) > 0
46+
47+
48+ @pytest .mark .skipolddriver
49+ def test_put_with_https_proxy_and_no_proxy_regression (
50+ conn_cnx , tmp_path , mitm_proxy , monkeypatch
51+ ):
52+ """SNOW-2865839: PUT fails with TypeError when HTTPS_PROXY and NO_PROXY are set.
53+
54+ From bug report:
55+ "HTTPS_PROXY=http://localhost:8080 NO_PROXY='google.com' python test.py"
56+ causes TypeError during PUT operations.
57+
58+ Bug flow:
59+ 1. HTTPS_PROXY set (mitmproxy)
60+ 2. NO_PROXY set with ANY value (e.g., "google.com")
61+ 3. Execute PUT operation
62+ 4. storage_client passes bytes URL to use_session()
63+ 5. Without fix: TypeError: inet_aton() argument 1 must be str, not bytes
64+ 6. With fix: PUT succeeds
65+ """
66+ test_file = tmp_path / "test_data.csv"
67+ test_file .write_text ("col1,col2\n 1,2\n 3,4\n " )
68+
69+ # Configure environment to use mitmproxy
70+ mitm_proxy .set_env_vars (monkeypatch )
71+
72+ # Set NO_PROXY with arbitrary value (from bug report)
73+ monkeypatch .setenv ("NO_PROXY" , "google.com" )
74+
75+ with conn_cnx (disable_ocsp_checks = True ) as conn :
76+ with conn .cursor () as cur :
77+ stage_name = random_string (5 , "test_no_proxy_" )
78+ cur .execute (f"CREATE TEMPORARY STAGE { stage_name } " )
79+
80+ # This is where the bug occurs - storage_client passes bytes URL
81+ put_result = cur .execute (
82+ f"PUT 'file://{ test_file } ' @{ stage_name } "
83+ ).fetchall ()
84+
85+ assert len (put_result ) > 0
86+ assert put_result [0 ][6 ] == "UPLOADED"
87+
88+ ls_result = cur .execute (f"LIST @{ stage_name } " ).fetchall ()
89+ assert len (ls_result ) > 0
0 commit comments