zapier / zapier-platform

The SDK for you to build an integration on Zapier

Home Page:https://platform.zapier.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

watfordsuzy opened this issue · comments

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.
commented

Getting same problem too, please fix

The current hack to make the error go away:

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

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