From 7c7a4171181fba44359b81748b692d4ee07e28d2 Mon Sep 17 00:00:00 2001 From: colby-oai <228809017+colby-oai@users.noreply.github.com> Date: Wed, 29 Apr 2026 10:17:04 -0400 Subject: [PATCH] dont change UploadedOpenAiFile shape --- codex-rs/codex-api/src/files.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/codex-rs/codex-api/src/files.rs b/codex-rs/codex-api/src/files.rs index f0ae8c163b..69d8505b12 100644 --- a/codex-rs/codex-api/src/files.rs +++ b/codex-rs/codex-api/src/files.rs @@ -27,7 +27,7 @@ pub struct UploadedOpenAiFile { pub file_name: String, pub file_size_bytes: u64, pub mime_type: Option, - pub path: Option, + pub path: PathBuf, } #[derive(Debug, thiserror::Error)] @@ -140,7 +140,7 @@ pub async fn upload_local_file( file_name, metadata.len(), reqwest::Body::wrap_stream(ReaderStream::new(upload_file)), - Some(path.to_path_buf()), + path.to_path_buf(), ) .await } @@ -152,13 +152,14 @@ pub async fn upload_file_bytes( contents: Vec, ) -> Result { let file_size_bytes = contents.len() as u64; + let source_path = PathBuf::from(file_name.clone()); upload_file_body_with_source_path( base_url, auth, file_name, file_size_bytes, reqwest::Body::from(contents), - /*source_path*/ None, + source_path, ) .await } @@ -169,13 +170,11 @@ async fn upload_file_body_with_source_path( file_name: String, file_size_bytes: u64, body: reqwest::Body, - source_path: Option, + source_path: PathBuf, ) -> Result { if file_size_bytes > OPENAI_FILE_UPLOAD_LIMIT_BYTES { return Err(OpenAiFileError::FileTooLarge { - path: source_path - .clone() - .unwrap_or_else(|| PathBuf::from(file_name.clone())), + path: source_path.clone(), size_bytes: file_size_bytes, limit_bytes: OPENAI_FILE_UPLOAD_LIMIT_BYTES, });