Skip to content

Commit bd4a7db

Browse files
ayushclaude
andcommitted
Fix FormParam dropped when FileParam present in client requests
formDataBody overwrites the urlencoded body, losing form fields. Include form params as multipart text parts alongside file parts. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 7cf2734 commit bd4a7db

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

webapi/src/WebApi/Client.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ toClientRequest extraUnres clientReq req = do
188188
fileParts = if Prelude.null filePar
189189
then []
190190
else Prelude.map (\(pname, finfo) -> HC.partFileSource (decodeUtf8 pname) (fileContent finfo)) filePar
191+
formParts = Prelude.map (\(pname, pval) -> HC.partBS (decodeUtf8 pname) pval) formPar
191192
cReqMP = if Prelude.null filePar && Prelude.null formPar
192193
then case partEncs of
193194
(_ : _) -> do
@@ -196,7 +197,7 @@ toClientRequest extraUnres clientReq req = do
196197
, HC.requestBody = HC.RequestBodyLBS $ toLazyByteString b
197198
}
198199
[] -> return cReqUE
199-
else if not (Prelude.null filePar) then HC.formDataBody fileParts cReqUE else return cReqUE
200+
else if not (Prelude.null filePar) then HC.formDataBody (formParts ++ fileParts) cReqQP else return cReqUE
200201
s <- cReqMP
201202
let s' = s { HC.method = singMethod (Proxy :: Proxy m)
202203
, HC.path = uriPath

0 commit comments

Comments
 (0)