From 535865fdebc4d029e9a183429b4f8599ac51897f Mon Sep 17 00:00:00 2001 From: Maintainer Bruno Date: Fri, 27 Jun 2025 00:08:10 +0530 Subject: [PATCH] fix(import): handle repeated query keys and improve error handling in curl import --- packages/bruno-app/src/utils/curl/curl-to-json.js | 8 ++++++-- packages/bruno-app/src/utils/curl/index.js | 4 ++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/bruno-app/src/utils/curl/curl-to-json.js b/packages/bruno-app/src/utils/curl/curl-to-json.js index 72aa22812..4897f5a2d 100644 --- a/packages/bruno-app/src/utils/curl/curl-to-json.js +++ b/packages/bruno-app/src/utils/curl/curl-to-json.js @@ -26,7 +26,7 @@ function getQueries(request) { const rawValue = request.query[paramName]; let paramValue; if (Array.isArray(rawValue)) { - paramValue = rawValue.map(repr); + paramValue = rawValue.map(value => repr(value, false)); } else { paramValue = repr(rawValue); } @@ -139,6 +139,10 @@ function getFilesString(request) { const curlToJson = (curlCommand) => { const request = parseCurlCommand(curlCommand); + if (!request?.url) { + return null; + } + const requestJson = {}; // curl automatically prepends 'http' if the scheme is missing, but python fails and returns an error @@ -207,7 +211,7 @@ const curlToJson = (curlCommand) => { } } - return Object.keys(requestJson).length ? requestJson : {}; + return Object.keys(requestJson).length ? requestJson : null; }; export default curlToJson; diff --git a/packages/bruno-app/src/utils/curl/index.js b/packages/bruno-app/src/utils/curl/index.js index 9a986b4de..0b4d894cd 100644 --- a/packages/bruno-app/src/utils/curl/index.js +++ b/packages/bruno-app/src/utils/curl/index.js @@ -34,6 +34,10 @@ export const getRequestFromCurlCommand = (curlCommand, requestType = 'http-reque } const request = curlToJson(curlCommand); + if (!request || !request.url) { + return null; + } + const parsedHeaders = request?.headers; const headers = parsedHeaders &&