hcengineering/platform · error

No such key

Error message

No such key

What it means

The files handler checks storageAdapter.stat for the requested blob before serving it. When stat returns undefined the key does not exist in storage, so the server logs 'No such key' and responds HTTP 404.

Source

Thrown at server/front/src/index.ts:495

          const wsIds = await getWorkspaceIds(ctx, token, req.path)
          if (wsIds === null) {
            res.status(403).send()
            return
          }

          const uuid = req.params.file ?? req.query.file
          if (uuid === undefined) {
            res.status(404).send()
            return
          }

          let blobInfo = await ctx.with('stat', {}, (ctx) => config.storageAdapter.stat(ctx, wsIds, uuid), {
            workspace: wsIds.uuid
          })

          if (blobInfo === undefined) {
            ctx.error('No such key', { file: uuid, workspace: wsIds.uuid })
            res.status(404).send()
            return
          }

          if (req.method === 'HEAD') {
            res.writeHead(200, {
              'accept-ranges': 'bytes',
              connection: 'keep-alive',
              'Keep-Alive': 'timeout=5',
              'content-type': blobInfo.contentType,
              'content-length': blobInfo.size,
              'content-security-policy': "default-src 'none';",
              Etag: blobInfo.etag,
              'Last-Modified': new Date(blobInfo.modifiedOn).toISOString()
            })
            res.status(200)

            res.end()
            return

View on GitHub (pinned to 63e28dc964)

Solutions

  1. Verify the file uuid exists in the target workspace's storage (check via storage console/CLI).
  2. Re-upload the file if it was deleted or lost in migration.
  3. Ensure the request targets the correct workspace containing the blob.
  4. Handle 404 on the client by removing stale references.

Example fix

// before
const res = await fetch(`/files?file=${uuid}`)
// after
const res = await fetch(`/files?file=${uuid}`)
if (res.status === 404) {
  await reuploadFile(uuid)
}
Defensive patterns

Strategy: fallback

Validate before calling

async function fileExists(frontUrl: string, fileUuid: string): Promise<boolean> {
  const res = await fetch(`${frontUrl}/files?file=${fileUuid}`, { method: 'HEAD' })
  return res.status !== 404
}

Type guard

function isFileUuid(uuid: unknown): uuid is string {
  return typeof uuid === 'string' && /^[0-9a-f-]{36}$/i.test(uuid)
}

Try / catch

const res = await fetch(`/files?file=${uuid}`)
if (res.status === 404) {
  console.warn(`file ${uuid} missing in workspace; restoring from backup`)
  await restoreFile(uuid) // fallback path
  return
}
return await res.blob()

Prevention

When it happens

Trigger: GET/HEAD /files?file=<uuid> where the blob uuid is absent from the workspace's storage (already deleted, never uploaded, or wrong uuid).

Common situations: Client caching or bookmarking file URLs after deletion; data migration losing blobs; typos/wrong workspace in the file uuid; uploads that silently failed earlier.

Related errors


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