{"record":{"id":"29fb09238d0e4abf","repo":"hcengineering/platform","slug":"bad-datalake-response","errorCode":null,"errorMessage":"Bad datalake response: ","messagePattern":"Bad datalake response: ","errorType":"exception","errorClass":"DatalakeError","httpStatus":null,"severity":"error","filePath":"foundations/server/packages/datalake/src/client.ts","lineNumber":288,"sourceCode":"    const file = new File([new Uint8Array(buffer)], objectName, {\n      type: params.type,\n      lastModified: params.lastModified\n    })\n\n    const form = new FormData()\n    form.append('file', file)\n\n    const response = await fetchSafe(ctx, url, {\n      method: 'POST',\n      body: form as unknown as BodyInit,\n      headers: {\n        ...this.headers\n      }\n    })\n\n    const result = (await response.json()) as BlobUploadResult[]\n    if (result.length !== 1) {\n      throw new DatalakeError('Bad datalake response: ' + result.toString())\n    }\n\n    const uploadResult = result[0]\n\n    if ('error' in uploadResult) {\n      throw new DatalakeError('Upload failed: ' + uploadResult.error)\n    }\n\n    return uploadResult.metadata\n  }\n\n  async uploadWithMultipart (\n    ctx: MeasureContext,\n    workspace: WorkspaceUuid,\n    objectName: string,\n    stream: Readable | Buffer | string,\n    params: UploadObjectParams\n  ): Promise<ObjectMetadata> {","sourceCodeStart":270,"sourceCodeEnd":306,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/foundations/server/packages/datalake/src/client.ts#L270-L306","documentation":"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.","triggerScenarios":"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.","commonSituations":"Datalake client and server version mismatch (server API changed); hitting a wrong/older endpoint; an error page returned as JSON with a different shape.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isSingleBlobUploadResult(r: unknown): r is [BlobUploadResult] {\n  return Array.isArray(r) && r.length === 1 && typeof r[0] === 'object' && r[0] !== null\n}","tryCatchPattern":"try {\n  await client.putObject(ctx, workspace, objectName, stream)\n} catch (err) {\n  if (err instanceof DatalakeError && err.message.startsWith('Bad datalake response')) {\n    // inspect raw server response; check client/server version match\n  } else throw err\n}","preventionTips":["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"],"tags":["datalake","network","api-contract"],"backgroundTag":"unexpected-response-format","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}