hcengineering/platform · error · DatalakeError
Bad datalake response:
Error message
Bad datalake response:
What it means
uploadWithFormData parses the upload endpoint's JSON response as BlobUploadResult[] and expects exactly one result. Any other array length throws DatalakeError('Bad datalake response: ...'), indicating the server response shape differs from the expected single-blob result.
Source
Thrown at foundations/server/packages/datalake/src/client.ts:288
const file = new File([new Uint8Array(buffer)], objectName, {
type: params.type,
lastModified: params.lastModified
})
const form = new FormData()
form.append('file', file)
const response = await fetchSafe(ctx, url, {
method: 'POST',
body: form as unknown as BodyInit,
headers: {
...this.headers
}
})
const result = (await response.json()) as BlobUploadResult[]
if (result.length !== 1) {
throw new DatalakeError('Bad datalake response: ' + result.toString())
}
const uploadResult = result[0]
if ('error' in uploadResult) {
throw new DatalakeError('Upload failed: ' + uploadResult.error)
}
return uploadResult.metadata
}
async uploadWithMultipart (
ctx: MeasureContext,
workspace: WorkspaceUuid,
objectName: string,
stream: Readable | Buffer | string,
params: UploadObjectParams
): Promise<ObjectMetadata> {View on GitHub (pinned to 63e28dc964)
Solutions
- Check client/server version compatibility of the datalake API
- Log/inspect the raw response body to see the actual shape returned
- Verify the upload URL points at the correct form-upload endpoint
Defensive patterns
Strategy: try-catch
Type guard
function isSingleBlobUploadResult(r: unknown): r is [BlobUploadResult] {
return Array.isArray(r) && r.length === 1 && typeof r[0] === 'object' && r[0] !== null
} Try / catch
try {
await client.putObject(ctx, workspace, objectName, stream)
} catch (err) {
if (err instanceof DatalakeError && err.message.startsWith('Bad datalake response')) {
// inspect raw server response; check client/server version match
} else throw err
} Prevention
- Keep datalake client and server versions in sync
- Pin and test against the documented upload API contract
- Log raw response bodies on unexpected shapes for diagnostics
When it happens
Trigger: Datalake server (or an intermediate proxy) returns an empty array, multiple results, or a non-batch-shaped JSON body to the form-data upload POST.
Common situations: Datalake client and server version mismatch (server API changed); hitting a wrong/older endpoint; an error page returned as JSON with a different shape.
Related errors
- Missing response body
- Failed to start multipart upload
- "npm view" returned error code ${npmVersionSpawnResult.statu
- Unable to resolve version ${version} of package ${name}: ${e
- response.statusText
AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29).
Data as JSON: /api/errors/29fb09238d0e4abf.
Report an issue: GitHub.