Budibase/budibase · error

Unable to retrieve stream - invalid response

Error message

Unable to retrieve stream - invalid response

What it means

getReadStream obtains an object from the store via the S3 client's getObject and requires the response Body to be an instance of stream.Readable (AWS SDK v3 should return a Readable). If the Body is missing or is not a Readable (e.g. it's a Blob/Uint8Array depending on SDK response type configuration), the function refuses to return a broken stream and throws.

Source

Thrown at packages/backend-core/src/objectStore/objectStore.ts:788

  return tmpPath
}

export async function getReadStream(
  bucketName: string,
  path: string
): Promise<{ stream: Readable; contentLength?: number; contentType?: string }> {
  return await tracer.trace("getReadStream", async span => {
    bucketName = sanitizeBucket(bucketName)
    path = sanitizeKey(path)
    span.addTags({ bucketName, path })
    const client = ObjectStore()
    const params = {
      Bucket: bucketName,
      Key: path,
    }
    const response = await client.getObject(params)
    if (!response.Body || !(response.Body instanceof stream.Readable)) {
      throw new Error("Unable to retrieve stream - invalid response")
    }
    span.addTags({
      contentLength: response.ContentLength,
      contentType: response.ContentType,
    })
    return {
      stream: response.Body,

      contentLength: response.ContentLength,
      contentType: response.ContentType,
    }
  })
}

export async function getObjectMetadata(
  bucket: string,
  path: string
): Promise<HeadObjectCommandOutput> {

View on GitHub (pinned to a81a902e9a)

Solutions

  1. Confirm you are running the Node build of the AWS SDK v3 with no response-body override (Body must be stream.Readable); check for conflicting @smithy/node-http-handler config
  2. Verify the object exists and is non-empty in the bucket via a direct client headObject or console
  3. If using MinIO, verify MINIO_URL and endpoint config so you are not hitting a gateway that returns malformed responses
  4. Re-upload the object if it is zero-byte/corrupted

Example fix

// before
const { stream } = await objectStore.getReadStream(bucket, key)
// after
let stream
try {
  ;({ stream } = await objectStore.getReadStream(bucket, key))
} catch (err) {
  if (err.message.includes("Unable to retrieve stream")) throw new Error("Object unavailable: " + key)
  throw err
}
Defensive patterns

Strategy: type-guard

Validate before calling

const meta = await objectStore.getObjectMetadata(bucket, path)
if (!meta || (meta.ContentLength ?? 0) === 0) throw new Error("Object empty or missing")

Type guard

function isNodeStream(b: unknown): b is import("stream").Readable {
  return b instanceof (await import("stream")).Readable
}

Try / catch

try {
  const { stream } = await objectStore.getReadStream(bucket, path)
} catch (err) {
  if (err.message.includes("Unable to retrieve stream")) {
    // object missing or SDK returned non-stream body
  }
  throw err
}

Prevention

When it happens

Trigger: client.getObject returns successfully but response.Body is null/undefined, or Body is not a stream.Readable — typically when the object is empty, when the SDK response body type differs (requestStreamCollector/response body type mismatch), or an S3-compatible endpoint returns a non-standard response shape.

Common situations: Reading automation/file attachments from MinIO with a misconfigured endpoint, using an AWS SDK configuration where the body is deserialized as a Blob (e.g. browser-style SDK settings) instead of a Node stream, or reading an object that was truncated to zero bytes.

Related errors


AI-assisted analysis of Budibase/budibase@a81a902e9a (2026-08-29). Data as JSON: /api/errors/54de84da2ae63a4a. Report an issue: GitHub.