Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
IkeOTL opened this issue Oct 31, 2024 · 5 comments
Closed
Assignees
Labels
bug Something isn't working status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close type:bug A broken experience

Comments

@IkeOTL
Copy link

IkeOTL commented Oct 31, 2024

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

@github-project-automation github-project-automation bot moved this to Needs Triage 🔍 in Kiota Oct 31, 2024
@andrueastman
Copy link
Member

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.

* KiotaClientFactory.create(undefined, [middleware1, middleware2]);

@rkodev Any chance this is related to compression handler issues at #1442 as well?

@andrueastman andrueastman moved this from Needs Triage 🔍 to Todo 📃 in Kiota Nov 7, 2024
@andrueastman andrueastman added bug Something isn't working type:bug A broken experience labels Nov 7, 2024
@rkodev rkodev self-assigned this Nov 7, 2024
@rkodev
Copy link
Contributor

rkodev commented Nov 26, 2024

Hi @IkeOTL, it looks like the issue was with zlib compression that has been dropped with version 77. Kindly update your dependecies to version 77 and share if you still have the problem

@rkodev rkodev removed their assignment Nov 26, 2024
@rkodev rkodev added the status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close label Nov 26, 2024
@baywet baywet moved this from Todo 📃 to In Review 💭 in Kiota Nov 26, 2024
@IkeOTL
Copy link
Author

IkeOTL commented Nov 26, 2024

@rkodev I've updated to "@microsoft/kiota-bundle": "^1.0.0-preview.77" but now my PUT request is producing garbage. I'm assuming its compression?

Image

@rkodev
Copy link
Contributor

rkodev commented Nov 27, 2024

Yes, this is as a result of compression. You can disable compression if you would like to see the payload

    const http = KiotaClientFactory.create(undefined, [
      new RetryHandler(), new RedirectHandler(), new ParametersNameDecodingHandler(), new UserAgentHandler(),  new HeadersInspectionHandler()
    ])
  
    const adapter = new FetchRequestAdapter(new BearerAuthenticationProvider(), undefined, undefined, http);
    const client = createApiClient(adapter);

    client.api.endpoint.post({
      field: "testdata",
    })

@baywet
Copy link
Member

baywet commented Nov 27, 2024

If you want to follow along or contribute to the compression discussion #1439

@IkeOTL IkeOTL closed this as completed Nov 27, 2024
@github-project-automation github-project-automation bot moved this from In Review 💭 to Done ✔️ in Kiota Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close type:bug A broken experience
Projects
Archived in project
Development

No branches or pull requests

4 participants