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>
This commit is contained in:
Shekhu☺️ 2026-03-26 20:56:36 +05:30 committed by GitHub
parent 744f434698
commit b728f5da24
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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 || "<binary-file>"
return {
mimeType: req.body.contentType,
text: `@${filename}`,
}
}
return { return {
mimeType: req.body.contentType, // Let's assume by default content type is JSON mimeType: req.body.contentType, // Let's assume by default content type is JSON
text: (req.body.body as string) ?? "", text: (req.body.body as string) ?? "",