hcengineering/platform · error · HttpError

Missing blob name

Error message

Missing blob name

What it means

withBlob validates req.params.name and throws HttpError 400 'Missing blob name' when the name param is undefined or empty. This runs after the workspace check in the same middleware.

Source

Thrown at pods/preview/src/middleware.ts:83

    next(err)
  }
}

/**
 * Validates blob route params and ensures the caller's token grants access to
 * the workspace taken from the URL. Must run after `withAuthorization`, which
 * guarantees a token is present.
 */
export const withBlob = (req: RequestWithAuth, res: Response, next: NextFunction): void => {
  try {
    const workspace = req.params.workspace
    const name = req.params.name

    if (workspace === undefined || workspace === '') {
      throw new HttpError(400, 'Missing workspace')
    }
    if (name === undefined || name === '') {
      throw new HttpError(400, 'Missing blob name')
    }

    const token = req.token
    if (token == null) {
      throw new HttpError(401, 'Unauthorized')
    }

    const hasWorkspaceAccess =
      (token.workspace as string) === workspace || token.account === systemAccountUuid || token.extra?.admin === 'true'
    if (!hasWorkspaceAccess) {
      throw new HttpError(401, 'Unauthorized')
    }

    next()
  } catch (err: any) {
    next(err)
  }
}

View on GitHub (pinned to 63e28dc964)

Solutions

  1. Append the blob name to the request URL (/blob/{workspace}/{name})
  2. Ensure the blob name variable is set before issuing the request
  3. Verify the express route defines :name so req.params.name is populated
  4. Encode the blob name (encodeURIComponent) so special characters don't break the path

Example fix

// before
fetch(`/blob/${workspace}/${name}`)
// after
if (!name) throw new Error('blob name is required')
fetch(`/blob/${encodeURIComponent(workspace)}/${encodeURIComponent(name)}`)
Defensive patterns

Strategy: validation

Validate before calling

if (!isNonEmptyString(name)) {
  throw new HttpError(400, 'blob name is required')
}
const url = `/blob/${encodeURIComponent(workspace)}/${encodeURIComponent(name)}`

Type guard

function isNonEmptyString (v: unknown): v is string {
  return typeof v === 'string' && v.trim().length > 0
}

Try / catch

try {
  const res = await fetch(url)
  if (res.status === 400) {
    console.error('Check blob request params: workspace and name must be non-empty')
  }
} catch (err) { /* handle */ }

Prevention

When it happens

Trigger: Blob endpoint request where the :name route parameter is absent or empty — e.g. URL ends at /blob/{workspace}/ with no blob name.

Common situations: Trailing-slash URL missing the filename; client variable holding the blob name is null/undefined at request time; route pattern mismatch so name isn't captured.

Understand the failure class

Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.

Related errors


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