hcengineering/platform · warning

missing filename

Error message

missing filename

What it means

handleS3CreateBlob (S3-compatible API) requires req.body.filename to create a blob. When filename is null/undefined the handler responds 400 'missing filename'. The filename is used as the object key/metadata via datalake.create.

Source

Thrown at services/datalake/pod-datalake/src/handlers/s3.ts:43

  res: Response,
  datalake: Datalake
): Promise<void> {
  const workspace = req.params.workspace as WorkspaceUuid
  const { location, bucket } = await datalake.selectStorage(ctx, workspace)
  res.status(200).json({ location, bucket: bucket.bucket })
}

export async function handleS3CreateBlob (
  ctx: MeasureContext,
  req: Request,
  res: Response,
  datalake: Datalake
): Promise<void> {
  const { name } = req.params
  const workspace = req.params.workspace as WorkspaceUuid
  const filename = req.body.filename as string
  if (filename == null) {
    res.status(400).send('missing filename')
    return
  }

  try {
    await datalake.create(ctx, workspace, name, filename)
    res.status(200).send()
  } catch (err: any) {
    Analytics.handleError(err)
    const error = err instanceof Error ? err.message : String(err)
    ctx.error('failed to create blob', { workspace, name, error })
    res.status(500).send()
  }
}

View on GitHub (pinned to 63e28dc964)

Solutions

  1. Include "filename" in the JSON body of the create request.
  2. Set Content-Type: application/json so the body parser populates req.body.
  3. If migrating from the plain upload API, map the path name into the filename field for this S3 endpoint.

Example fix

// before
curl -X POST $URL -d '{}'
// after
curl -X POST $URL -H 'Content-Type: application/json' -d '{"filename":"report.pdf"}'
Defensive patterns

Strategy: validation

Validate before calling

if (!filename) {
  throw new Error('filename is required to create an S3 blob')
}

Type guard

function hasFilename(b: unknown): b is { filename: string } {
  return !!b && typeof (b as any).filename === 'string' && (b as any).filename.length > 0
}

Try / catch

const res = await fetch(url, { method: 'POST', headers: json, body: JSON.stringify({ filename }) })
if (res.status === 400 && (await res.text()) === 'missing filename') {
  throw new Error('include filename in the request body')
}

Prevention

When it happens

Trigger: POSTing to the S3 create-blob route without a filename field in the JSON body, sending filename: null, or sending a non-JSON body so body parsing yields no filename.

Common situations: S3 clients/tools that don't send this custom extension field; forgetting Content-Type: application/json; scripts copied from the plain upload endpoint that pass the name only as a path param.

Related errors


AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29). Data as JSON: /api/errors/3e82611c890015f6. Report an issue: GitHub.