hcengineering/platform · error
'data' is missing
Error message
'data' is missing
What it means
The pod-notification push handler responds HTTP 400 with { err: "'data' is missing" } when req.body.data is undefined. The handler builds a PushData from body.data and needs it to compose the web-push notification payload, so it rejects the request before looking at subscriptions.
Source
Thrown at services/notification/pod-notification/src/main.ts:69
if (token !== config.AuthToken) {
res.status(401).send({ err: 'Invalid auth token' })
return false
}
}
return true
}
const endpoints: Endpoint[] = [
{
endpoint: '/web-push',
type: 'post',
handler: async (req, res) => {
if (!checkAuth(req, res)) {
return
}
const data: PushData | undefined = req.body?.data
if (data === undefined) {
res.status(400).send({ err: "'data' is missing" })
return
}
const subscriptions: PushSubscription[] | undefined = req.body?.subscriptions
if (subscriptions === undefined) {
res.status(400).send({ err: "'subscriptions' is missing" })
return
}
if (!webpushInitDone) {
res.json({ result: [] }).end()
return
}
const result = await sendPushToSubscription(ctx, subscriptions, data)
res.json({ result }).end()
}
}
]
View on GitHub (pinned to 63e28dc964)
Solutions
- Include a valid 'data' object in the JSON body: {"data":{...},"subscriptions":[...]}.
- Set Content-Type: application/json and confirm the body is not empty after proxies/gateways.
- Match the PushData shape expected by the service (check its type definition) rather than sending arbitrary fields.
- Validate the payload client-side before sending (see type guard) to fail fast with a clearer message.
Example fix
// before
post(pushUrl, { subscriptions })
// after
post(pushUrl, { data: { title: 'Hi', body: 'Hello' }, subscriptions }) Defensive patterns
Strategy: validation
Validate before calling
function hasPushData(body: unknown): boolean {
const d = (body as any)?.data
return d !== undefined && d !== null && typeof d === 'object'
}
if (!hasPushData(payload)) throw new Error("push request requires a 'data' object") Type guard
function hasPushData(b: unknown): b is { data: object; subscriptions: unknown[] } {
const d = (b as any)?.data
return typeof d === 'object' && d !== null
} Try / catch
const res = await fetch(pushUrl, opts)
if (res.status === 400) {
const { err } = await res.json()
if (err?.includes("'data' is missing")) throw new Error('push payload must include data')
} Prevention
- Build push requests through one typed helper so data is always present
- Send Content-Type: application/json explicitly
- Keep the field named exactly 'data' — no client-side renames
When it happens
Trigger: POST to the push endpoint (passing checkAuth) with a body lacking the 'data' object, a non-JSON body, or data nested one level too deep (e.g. { payload: { data } } instead of { data }).
Common situations: Wrong Content-Type so express.json() never populates req.body; renaming the field in the client ('notification', 'payload', 'message') while the service expects 'data'; older clients built for a schema where data was optional; gateway stripping the body on forwarded POSTs.
Related errors
- 'subscriptions' is missing
- Failed to load server config
- getDisplayMedia not supported
- No screen access granted
- 'from' is missing
AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29).
Data as JSON: /api/errors/a327fa2701d2e93a.
Report an issue: GitHub.