Budibase/budibase · error
Stream to upload is invalid/undefined
Error message
Stream to upload is invalid/undefined
What it means
streamUploadInternal uploads a readable stream to the object store; it validates the stream argument first and throws this error when the stream is falsy (undefined/null). This prevents passing garbage to the S3 SDK's Upload, which would fail less clearly later.
Source
Thrown at packages/backend-core/src/objectStore/objectStore.ts:274
type StreamUploadInternalOptions = {
client: ReturnType<typeof ObjectStore>
bucket: string
filename: string
stream?: StreamTypes
type?: string | null
extra?: any
}
const streamUploadInternal = async ({
client,
bucket,
filename,
stream,
type,
extra,
}: StreamUploadInternalOptions) => {
if (!stream) {
throw new Error("Stream to upload is invalid/undefined")
}
const contentType = resolveContentType(filename, type)
const key = sanitizeKey(filename)
const params = {
Bucket: bucket,
Key: key,
Body: stream,
ContentType: contentType,
...(extra ?? {}),
}
const upload = new Upload({ client, params })
const details = await upload.done()
return {
details,
contentType,View on GitHub (pinned to a81a902e9a)
Solutions
- Ensure a valid readable stream is passed (e.g. fs.createReadStream(existingPath) or a pipeline() result) before calling upload
- Check that the source file/resource exists and is readable at upload time
- Log the stream argument at the call site to confirm it is not undefined (common: wrong variable/path)
- Pass a Buffer via Readable.from(buffer) if your data is in memory rather than a stream
Example fix
// before
await streamUpload({ bucket, filename: key, stream: maybeStream }) // undefined when file missing
// after
if (!fs.existsSync(filePath)) throw new Error("file missing")
await streamUpload({ bucket, filename: key, stream: fs.createReadStream(filePath) }) Defensive patterns
Strategy: type-guard
Validate before calling
function assertStream(stream) {
if (!stream || typeof stream.pipe !== "function") {
throw new Error("upload requires a readable stream")
}
} Type guard
import { Readable } from "stream"
function isReadableStream(value): value is Readable {
return value instanceof Readable || (value != null && typeof value.pipe === "function")
} Try / catch
try {
await upload({ bucket, filename: key, stream })
} catch (err) {
if (String(err.message) === "Stream to upload is invalid/undefined") {
// check the call site: the stream source failed or was never created
}
} Prevention
- Check the stream source (file exists, request body present) before calling upload
- Guard helper functions with isReadableStream before passing streams down
- Avoid swallowing errors from fs.createReadStream / pipeline setup upstream
- Wrap in-memory data with Readable.from(buffer) rather than passing the buffer directly
When it happens
Trigger: Calling upload/streamUploadInternal (directly or via upload of attachments, client libraries, etc.) where the caller passed no stream — e.g. reading a file that doesn't exist producing undefined, or a pipeline returning an empty value.
Common situations: fs.createReadStream on a nonexistent path upstream throwing/being swallowed; automation or API upload with an empty body; a previous transform step in a stream pipeline returning undefined; passing a string/Buffer path instead of an actual stream.
Related errors
- Invalid object store key: path traversal is not allowed.
- Unable to retrieve stream - invalid response
- Plugin missing .js file.
- File is not valid - cannot upload.
- Plugin must be compressed into a gzipped tarball.
AI-assisted analysis of Budibase/budibase@a81a902e9a (2026-08-29).
Data as JSON: /api/errors/e82a8ff66483755a.
Report an issue: GitHub.