hcengineering/platform · warning

'event' or 'workspace' or 'type' is missing

Error message

'event' or 'workspace' or 'type' is missing

What it means

The calendar outcoming-sync HTTP endpoint validates that the request body contains 'event', 'workspace' and 'type' fields before forwarding the event to the account outcoming client. If any of the three is undefined, the handler short-circuits with HTTP 400 and this message. It is a guard against malformed client payloads, not a server fault.

Source

Thrown at services/calendar/pod-calendar/src/main.ts:173

        res.send()
      }
    },
    {
      endpoint: '/event',
      type: 'post',
      handler: async (req, res) => {
        const token = extractToken(req.headers)

        if (token === undefined) {
          res.status(401).send()
          return
        }

        const { event, workspace, type } = req.body

        if (event === undefined || workspace === undefined || type === undefined) {
          res.status(400).send({ err: "'event' or 'workspace' or 'type' is missing" })
          return
        }
        void OutcomingClient.push(ctx, accountClient, workspace, event, type).catch((err: any) => {
          ctx.error('Outcoming sync failed', { eventId: event.eventId, workspace, type, error: err.message })
        })
        res.send()
      }
    }
  ]

  const server = listen(createServer(endpoints), config.Port)

  const shutdown = (): void => {
    server.close(() => {
      watchController.stop()
      process.exit()
    })
  }

View on GitHub (pinned to 63e28dc964)

Solutions

  1. Include all three fields in the JSON body: event (object with eventId), workspace (workspace UUID string) and type.
  2. Ensure the request has Content-Type: application/json and an express json body parser is applied so req.body is populated.
  3. Check the caller for renamed fields after an API update and align with the handler destructuring in main.ts.

Example fix

// before
await fetch(url, { method: 'POST', body: JSON.stringify({ event, type }) })
// after
await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ event, workspace, type }) })
Defensive patterns

Strategy: validation

Validate before calling

if (event === undefined || workspace === undefined || type === undefined) {
  throw new Error('event, workspace and type are required before calling the sync endpoint')
}

Type guard

function isSyncBody(b: unknown): b is { event: { eventId: string }, workspace: string, type: string } {
  const o = b as any
  return !!o && o.event !== undefined && typeof o.event.eventId === 'string' && typeof o.workspace === 'string' && typeof o.type === 'string'
}

Try / catch

const res = await fetch(url, opts)
if (res.status === 400) {
  const body = await res.json()
  throw new Error(`sync rejected: ${body.err}`)
}

Prevention

When it happens

Trigger: POSTing to the calendar sync endpoint with a body missing req.body.event (the event object), req.body.workspace (the workspace UUID) or req.body.type (the sync type); e.g. sending { event, type } without workspace, or an empty body.

Common situations: Client SDKs or scripts calling the internal sync route by hand; JSON bodies where a field is serialized as null/omitted after upstream refactors renamed it; content-type not set to application/json so req.body is empty.

Related errors


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