From 6654d6c346dc7c07ecbf054b2719566b9cc1825d Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Fri, 9 Jan 2026 17:18:09 -0800 Subject: [PATCH] fix: add default headers only to new workspaces on insert (#356) --- crates/yaak-models/src/queries/workspaces.rs | 23 +++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/crates/yaak-models/src/queries/workspaces.rs b/crates/yaak-models/src/queries/workspaces.rs index b374c8de..682a608e 100644 --- a/crates/yaak-models/src/queries/workspaces.rs +++ b/crates/yaak-models/src/queries/workspaces.rs @@ -65,7 +65,28 @@ impl<'a> DbContext<'a> { } pub fn upsert_workspace(&self, w: &Workspace, source: &UpdateSource) -> Result { - self.upsert(w, source) + let mut workspace = w.clone(); + + // Add default headers only for NEW workspaces (empty ID means insert, not update) + // This prevents re-adding headers if a user intentionally removes all headers + if workspace.id.is_empty() && workspace.headers.is_empty() { + workspace.headers = vec![ + HttpRequestHeader { + enabled: true, + name: "User-Agent".to_string(), + value: "yaak".to_string(), + id: None, + }, + HttpRequestHeader { + enabled: true, + name: "Accept".to_string(), + value: "*/*".to_string(), + id: None, + }, + ]; + } + + self.upsert(&workspace, source) } pub fn resolve_auth_for_workspace(