hcengineering/platform · warning · PlatformError
BadRequest
BadRequest
Error message
BadRequest
What it means
BadRequest is thrown by updateWorkspaceInfo when required parameters are missing or empty: workspaceUuid is null/empty string, or event is null. This check runs after the service-allowlist check, so the caller is authorized but sent an incomplete payload. It signals malformed request data rather than an auth or state problem.
Source
Thrown at server/account/src/serviceOperations.ts:320
branding: Branding | null,
token: string,
params: {
workspaceUuid: WorkspaceUuid
event: WorkspaceEvent
version: Data<Version> // A worker version
progress: number
message?: string
}
): Promise<void> {
const { workspaceUuid, event, version, message } = params
const { extra } = decodeTokenVerbose(ctx, token)
if (!['workspace', 'tool'].includes(extra?.service)) {
throw new PlatformError(new Status(Severity.ERROR, platform.status.Forbidden, {}))
}
if (workspaceUuid == null || workspaceUuid === '' || event == null) {
throw new PlatformError(new Status(Severity.ERROR, platform.status.BadRequest, {}))
}
let progress = params.progress
const wsExists = await db.workspace.exists({ uuid: workspaceUuid })
if (!wsExists) {
throw new PlatformError(new Status(Severity.ERROR, platform.status.WorkspaceNotFound, { workspaceUuid }))
}
progress = Math.round(progress)
const ts = Date.now()
const update: Partial<WorkspaceStatus> = {}
const wsUpdate: Partial<Workspace> = {}
const query: Query<WorkspaceStatus> = { workspaceUuid }
// Only read status for certain events because it is not needed for others
// and it interferes with status updates when concurrency is high
let wsStatus: WorkspaceStatus | null = nullView on GitHub (pinned to 63e28dc964)
Solutions
- Validate workspaceUuid is a non-empty UUID string and event is non-null before calling updateWorkspaceInfo.
- Ensure the workspace was created and its UUID was received (await the create call) before sending status updates.
- Check serialization of the params object (no dropped fields from spread/JSON transforms).
- Return/log a clear client-side error instead of calling the API with incomplete data.
Example fix
// before
await accountClient.updateWorkspaceInfo(ctx, token, { workspaceUuid: wsId, event })
// after
if (!wsId || event == null) {
throw new Error(`updateWorkspaceInfo requires workspaceUuid and event, got wsId=${wsId}, event=${event}`)
}
await accountClient.updateWorkspaceInfo(ctx, token, { workspaceUuid: wsId, event }) Defensive patterns
Strategy: validation
Validate before calling
// Validate required params before the API call
if (workspaceUuid == null || workspaceUuid === '') {
throw new Error('workspaceUuid must be a non-empty UUID')
}
if (event == null) {
throw new Error('event is required for updateWorkspaceInfo')
} Type guard
function isValidUpdatePayload(p: UpdateWorkspaceInfoParams): p is UpdateWorkspaceInfoParams & { workspaceUuid: string; event: WorkspaceEvent } {
return p.workspaceUuid != null && p.workspaceUuid !== '' && p.event != null
} Try / catch
try {
await updateWorkspaceInfo(ctx, token, params)
} catch (err) {
if (err instanceof PlatformError && err.status.code === platform.status.BadRequest) {
log.error('updateWorkspaceInfo payload incomplete', { params })
return
}
throw err
} Prevention
- Enable TypeScript strict null checks so missing fields fail at compile time.
- Always await workspace creation and use the returned UUID before sending updates.
- Add a schema validator (e.g. zod) on params before calling internal APIs.
- Log the full payload when constructing requests to catch dropped fields early.
When it happens
Trigger: Passing workspaceUuid as '' or undefined, or omitting the event field, when calling updateWorkspaceInfo — e.g. an uninitialized workspace record ID, a variable not yet assigned, or an event enum/value that failed to serialize.
Common situations: Callers constructing the params object dynamically and skipping empty workspaceUuid; race where a workspace-create hasn't returned an ID yet; TypeScript strict mode off letting undefined through; event produced by a mapping function returning null on unknown workspace states.
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
- platform.status.BadRequest
- platform.status.BadRequest
- account.status.BadRequest
- account.status.BadRequest
- BadRequest
AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29).
Data as JSON: /api/errors/fd35c74889013669.
Report an issue: GitHub.