From b728f5da242047a66771a4e9715abb6db4a7eb22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Shekhu=E2=98=BA=EF=B8=8F?= <61787974+sh3xu@users.noreply.github.com> Date: Thu, 26 Mar 2026 20:56:36 +0530 Subject: [PATCH] fix(common): handle File objects in HAR postData text resolution (#5917) Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> Co-authored-by: James George <25279263+jamesgeorge007@users.noreply.github.com> --- .../src/helpers/new-codegen/har.ts | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/packages/hoppscotch-common/src/helpers/new-codegen/har.ts b/packages/hoppscotch-common/src/helpers/new-codegen/har.ts index b8c9e49c..c9fc285c 100644 --- a/packages/hoppscotch-common/src/helpers/new-codegen/har.ts +++ b/packages/hoppscotch-common/src/helpers/new-codegen/har.ts @@ -114,6 +114,29 @@ const buildHarPostData = (req: HoppRESTRequest): Har.PostData | undefined => { } } + // application/octet-stream bodies are File | null; emit @filename for file uploads + if (req.body.contentType === "application/octet-stream") { + const file = req.body.body + + if (!file) { + return { + mimeType: req.body.contentType, + text: "", + } + } + + // `path` exists in some desktop runtimes; `name` is the standard File field. + const filename = + "path" in file && typeof file.path === "string" && file.path + ? file.path + : file.name || "" + + return { + mimeType: req.body.contentType, + text: `@${filename}`, + } + } + return { mimeType: req.body.contentType, // Let's assume by default content type is JSON text: (req.body.body as string) ?? "",