From 34f2ae617884a55fd73ac876e71655c0515ff995 Mon Sep 17 00:00:00 2001 From: Udhay-Adithya Date: Sat, 27 Sep 2025 18:13:35 +0530 Subject: [PATCH] fix: cleanr body and formData in curl import --- .../chat/viewmodel/chat_viewmodel.dart | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/dashbot/features/chat/viewmodel/chat_viewmodel.dart b/lib/dashbot/features/chat/viewmodel/chat_viewmodel.dart index 57214129..6fc0b5f1 100644 --- a/lib/dashbot/features/chat/viewmodel/chat_viewmodel.dart +++ b/lib/dashbot/features/chat/viewmodel/chat_viewmodel.dart @@ -416,15 +416,18 @@ class ChatViewmodel extends StateNotifier { final withEnvUrl = await _maybeSubstituteBaseUrl(url, baseUrl); if (action.field == 'apply_to_selected') { if (requestId == null) return; + final replacingBody = + (formFlag || formData.isNotEmpty) ? '' : (body ?? ''); + final replacingFormData = + formData.isEmpty ? const [] : formData; collection.update( method: method, url: withEnvUrl, headers: headers, isHeaderEnabledList: List.filled(headers.length, true), - body: body, + body: replacingBody, bodyContentType: bodyContentType, - formData: formData.isEmpty ? null : formData, - // Wipe existing parameters and authentication to ensure clean state + formData: replacingFormData, params: const [], isParamEnabledList: const [], authModel: null, @@ -895,14 +898,19 @@ class ChatViewmodel extends StateNotifier { final withEnvUrl = await _maybeSubstituteBaseUrl(url, baseUrl); if (action.field == 'apply_to_selected') { if (requestId == null) return; + // Replacement semantics: ensure previous body/formData are cleared if absent in cURL + final replacingBody = + (formFlag || formData.isNotEmpty) ? '' : (body ?? ''); + final replacingFormData = + formData.isEmpty ? const [] : formData; collection.update( method: method, url: withEnvUrl, headers: headers, isHeaderEnabledList: List.filled(headers.length, true), - body: body, + body: replacingBody, bodyContentType: bodyContentType, - formData: formData.isEmpty ? null : formData, + formData: replacingFormData, // Wipe existing parameters and authentication to ensure clean state params: const [], isParamEnabledList: const [],