microsoft / kiota-typescript

TypeScript libraries for Kiota-generated API clients.
https://aka.ms/kiota/docs
MIT License
37 stars 31 forks source link

After upgrading: type error when POSTing body using a generated TS client #1464

Open IkeOTL opened 3 weeks ago

IkeOTL commented 3 weeks ago

I upgraded from

"@microsoft/kiota-abstractions": "^1.0.0-preview.57",
"@microsoft/kiota-http-fetchlibrary": "^1.0.0-preview.56",
"@microsoft/kiota-serialization-form": "^1.0.0-preview.46",
"@microsoft/kiota-serialization-json": "^1.0.0-preview.57",
"@microsoft/kiota-serialization-multipart": "^1.0.0-preview.35",
"@microsoft/kiota-serialization-text": "^1.0.0-preview.54",

to "@microsoft/kiota-bundle": "^1.0.0-preview.72"

And now I get this error when calling a POST function on a TS client generated using dotnet tool microsoft.openapi.kiota = 1.19.1 error:

TypeError: The "chunk" argument must be one of type string or Buffer. Received type object
    at validChunk (index.js:1:23577)
    at Writable.write (index.js:1:23989)
    at Writable.end (index.js:1:27532)
    at zlibBuffer (index.js:1:8869)
    at t.gzip (index.js:1:7829)
    at eval (compressionHandler.js:164:1)
    at new Promise (<anonymous>)
    at CompressionHandler.compressUsingZlib (compressionHandler.js:163:1)
    at async CompressionHandler.compressRequestBody (compressionHandler.js:153:1)
    at async CompressionHandler.executeInternal (compressionHandler.js:60:1)
    at async UserAgentHandler.addValue (userAgentHandler.js:53:1)
    at async RedirectHandler.executeWithRedirect (redirectHandler.js:105:1)
    at async RetryHandler.executeWithRetry (retryHandler.js:123:1)
    at async HttpClient.executeFetch (httpClient.js:53:1)
    at async eval (fetchRequestAdapter.js:481:1)
    at async eval (fetchRequestAdapter.js:176:1)
    at async eval (fetchRequestAdapter.js:163:1)
    at async fetchData (QueryAudioTable.tsx:50:19)
    at async onSubmit (QueryAudioTable.tsx:89:17)
    at async eval (index.esm.mjs:2293:1)

It seems that kiota's serializer is providing a Arraybuffer while the validChunk is expecting a string or Buffer. Maybe something is wrong with the compression middleware? Unfortunately I cannot figure out how to disable the compression middleware

andrueastman commented 2 weeks ago

Thanks for raising this @IkeOTL

Unfortunately I cannot figure out how to disable the compression middleware

At the moment, I believe you can use this example to create a httpclient and then pass it to the request adapter constructor.

https://github.com/microsoft/kiota-typescript/blob/fcef711faca59823910a41ba722466b14b3bda3a/packages/http/fetch/src/kiotaClientFactory.ts#L38

@rkodev Any chance this is related to compression handler issues at https://github.com/microsoft/kiota-typescript/issues/1442 as well?