Skip to content

Commit 009be9b

Browse files
committed
fix(sdk): address codex review feedback on #136
- helper: open with newline="" so CRLF/CR line endings reach the server byte-faithful instead of being silently normalized to \n. Adds a regression test for a Windows-authored config (b"line1\r\nline2\r\n"). - example: ship examples/sdk/default.conf so create_inference.py runs as-is without the user having to discover and create an extra file (matches how create_inference_vllm.py ships vllm_config.yaml). Signed-off-by: Honglin Cao <hocao@nvidia.com>
1 parent 82decf1 commit 009be9b

3 files changed

Lines changed: 21 additions & 1 deletion

File tree

centml/sdk/utils/config_file.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
# Field-level validation (size cap, filename charset, mount_path rules) is
1010
# left to the API so SDK doesn't drift when server limits change.
1111
def load_config_file_mount(path: str, mount_path: str, filename: Optional[str] = None) -> ConfigFileMount:
12-
with open(path, "r", encoding="utf-8") as f:
12+
# newline="" disables universal-newline translation so CRLF/CR line
13+
# endings reach the server byte-faithful instead of being normalized to \n.
14+
with open(path, "r", encoding="utf-8", newline="") as f:
1315
content = f.read()
1416
return ConfigFileMount(filename=filename or os.path.basename(path), mount_path=mount_path, content=content)

examples/sdk/default.conf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
server {
2+
listen 8080;
3+
location / {
4+
return 200 "hello from config_file\n";
5+
add_header Content-Type text/plain;
6+
}
7+
}

tests/test_sdk_config_file_helper.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,14 @@ def test_utf8_multibyte_content_roundtrips(tmp_path):
3939
def test_missing_file_raises_filenotfound(tmp_path):
4040
with pytest.raises(FileNotFoundError):
4141
load_config_file_mount(str(tmp_path / "does-not-exist.conf"), "/etc/x")
42+
43+
44+
def test_preserves_crlf_line_endings(tmp_path):
45+
# Windows-authored configs use \r\n; the helper must not silently
46+
# normalize them to \n when uploading to the server.
47+
src = tmp_path / "windows.conf"
48+
src.write_bytes(b"line1\r\nline2\r\n")
49+
50+
mount = load_config_file_mount(str(src), "/etc/app")
51+
52+
assert mount.content == "line1\r\nline2\r\n"

0 commit comments

Comments
 (0)