Skip to content

Commit f78edb7

Browse files
bnavettaoz-agent
andauthored
Handle null upload target fields (#10959)
## Description Use `serde_with::DefaultOnNull` on `UploadTarget::fields` so the Rust client treats an explicit JSON `null` the same as a missing field and deserializes it as an empty vector. This keeps local-to-cloud handoff snapshot uploads from failing when the server returns `"fields": null`. ## Linked Issue N/A - Slack request from `#pod-oz-handoff`. - [ ] The linked issue is labeled `ready-to-spec` or `ready-to-implement`. - [ ] Where appropriate, screenshots or a short video of the implementation are included below (especially for user-visible or UI changes). ## Testing - `cargo fmt --manifest-path /workspace/warp/app/Cargo.toml --check` - `CARGO_BUILD_JOBS=1 cargo nextest run --manifest-path /workspace/warp/Cargo.toml -p warp -E 'test(upload_target_deserializes_null_fields_as_empty)'` - `CARGO_BUILD_JOBS=1 cargo check --manifest-path /workspace/warp/Cargo.toml -p warp --lib` - [ ] I have manually tested my changes locally with `./script/run` ### Screenshots / Videos N/A - no UI changes. ## Agent Mode - [x] Warp Agent Mode - This PR was created via Warp's AI Agent Mode CHANGELOG-OZ: Fixed local-to-cloud handoff snapshot upload allocation when the server returns no upload form fields. _Conversation: https://staging.warp.dev/conversation/d49e5635-e39d-46d4-b6fd-12f04271a381_ _Run: https://oz.staging.warp.dev/runs/019e2875-6204-77b7-9d97-70b6a9e871d8_ _This PR was generated with [Oz](https://warp.dev/oz)._ Co-authored-by: Oz <oz-agent@warp.dev>
1 parent 3f0337d commit f78edb7

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

app/src/server/server_api/harness_support.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@ pub use super::presigned_upload::FileUploadBody;
2121
pub use super::presigned_upload::UploadBody;
2222

2323
/// A presigned upload target returned by the server.
24+
#[serde_with::serde_as]
2425
#[derive(Debug, Clone, serde::Deserialize)]
2526
pub struct UploadTarget {
2627
pub url: String,
2728
pub method: String,
2829
pub headers: HashMap<String, String>,
2930
/// Ordered multipart form fields for POST uploads.
3031
#[serde(default)]
32+
#[serde_as(deserialize_as = "serde_with::DefaultOnNull")]
3133
pub fields: Vec<UploadField>,
3234
}
3335

app/src/server/server_api/harness_support_tests.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
use crate::ai::artifacts::Artifact;
22

3+
#[test]
4+
fn upload_target_deserializes_null_fields_as_empty() {
5+
use super::UploadTarget;
6+
7+
let target: UploadTarget = serde_json::from_value(serde_json::json!({
8+
"url": "https://example.com/upload",
9+
"method": "PUT",
10+
"headers": {},
11+
"fields": null
12+
}))
13+
.unwrap();
14+
15+
assert_eq!(target.fields.len(), 0);
16+
}
17+
318
/// Assert that `Artifact`s serialize to the expected format for the /harness-support/report-artifact
419
/// endpoint.
520
/// If `Artifact` serialization changes, this test will catch it.

0 commit comments

Comments
 (0)