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

[Bug]: z.request when raw is true does not include buffer method on response object #734

Closed
watfordsuzy opened this issue Jan 22, 2024 · 3 comments · Fixed by #735
Closed
Labels
bug Something isn't working

Comments

@watfordsuzy
Copy link

watfordsuzy commented Jan 22, 2024

Bug Description

I'm not sure if this is an issue with your TypeScript type definitions or with the actual library, but contrary to the examples and error messages you receive, there is no buffer() method on RawHttpResponse or BaseHttpResponse.

The following example is invalid, at least for TS:
image

Reproduction Steps

import { ZObject } from 'zapier-platform-core' // 15.5.1 per package.json

const file = await z.request({
    url: download.item,
    raw: true,
})

// src/Hydrators.ts(34,44): error TS2339: Property 'buffer' does not exist on type 'RawHttpResponse'.
const buffer = await file.buffer() // CHOKE

Zapier Platform version

15.5.1

Node.js version

18.19.0

Your Operating System

macOS 14.2.1

npm/yarn version

10.2.3

App ID

198292

More Details

Received this on platform and adjusted my code to use await file.buffer():

While requesting "dev_file" from Our App (0.6.0) we ran into an error: You passed {raw: true} in request() - the response.content property is not available! Try response.body.pipe() for streaming, response.buffer() for a buffer, or response.text() for string.
@watfordsuzy watfordsuzy added the bug Something isn't working label Jan 22, 2024
@zacharytyhacz
Copy link

Getting same problem too, please fix

@watfordsuzy
Copy link
Author

The current hack to make the error go away:

import { Response } from 'node-fetch'
const buffer = await (file as unknown as Response).buffer()

@eliangcs
Copy link
Member

Thanks for reporting! The bug fix will be in the next release, likely v15.5.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants