hcengineering/platform · error · Error

Cannot create message, group not found: cardId = ${event.car

Error message

Cannot create message, group not found: cardId = ${event.cardId}, messageId = ${event.messageId}, created = ${event.date.toISOString()}

What it means

After validating messageId, createMessage looks up the message group for the card and date via `this.blob.getMessageGroupByDate(cardId, date)`. If no group exists, it throws this Error with cardId, messageId and created date embedded. It means storage cannot attach the message because the expected day-group blob for that card was never created.

Source

Thrown at foundations/communication/packages/server/src/middleware/storage.ts:237

    event.collaborators = added
    return {}
  }

  private async removeCollaborators (event: Enriched<RemoveCollaboratorsEvent>): Promise<Result> {
    if (event.collaborators.length === 0) return { skipPropagate: true }
    await this.db.removeCollaborators({ cardId: event.cardId, account: event.collaborators })

    return {}
  }

  private async createMessage (event: Enriched<CreateMessageEvent>): Promise<Result> {
    if (event.messageId == null) {
      throw new Error('Message id is required')
    }

    const group = await this.blob.getMessageGroupByDate(event.cardId, event.date)
    if (group == null) {
      throw new Error(
        `Cannot create message, group not found: cardId = ${event.cardId}, messageId = ${event.messageId}, created = ${event.date.toISOString()}`
      )
    }
    const result: CreateMessageResult = {
      messageId: event.messageId,
      created: event.date,
      blobId: group.blobId
    }
    const created = await this.db.createMessageMeta(
      event.cardId,
      event.messageId,
      event.socialId,
      event.date,
      group.blobId
    )

    if (!created) {
      return {

View on GitHub (pinned to 63e28dc964)

Solutions

  1. Ensure the card/message-group is created (initialize the group for the card/date) before dispatching message-create events.
  2. Check event ordering/delivery: verify the card-creation event was processed (idempotent retries, queue ordering).
  3. Verify the event `date` is correct (client clock skew can point at a date with no group).
  4. If the group was intentionally deleted, decide whether to recreate it or drop the stale event instead of failing.
  5. From the error's cardId/messageId/created fields, query blob storage to confirm the missing group and backfill it.

Example fix

// before
await storage.processEvent({ type: 'message.create', cardId: 'c1', messageId: 'm1', date: new Date(), ... })
// Error: Cannot create message, group not found: cardId = c1 ...
// after: create the group first
await blob.createMessageGroup('c1', date)
await storage.processEvent({ type: 'message.create', cardId: 'c1', messageId: 'm1', date, ... })
Defensive patterns

Strategy: validation

Validate before calling

async function assertGroupExists(blob, cardId, date) {
  const group = await blob.getMessageGroupByDate(cardId, date)
  if (group == null) throw new Error(`Message group for card ${cardId} on ${date.toISOString()} does not exist; create it first`)
}

Try / catch

try {
  await storage.processEvent(createMsgEvent)
} catch (e) {
  if (e.message.startsWith('Cannot create message, group not found')) {
    const { cardId, created } = parseGroupError(e.message)
    await blob.createMessageGroup(cardId, new Date(created))
    return retry(processEvent, createMsgEvent)
  }
  throw e
}

Prevention

When it happens

Trigger: A CreateMessageEvent arrives for a cardId whose message group for the event date does not exist in blob storage — typically the card/group was never initialized, was deleted, or the event date doesn't match any existing group.

Common situations: Events arriving out of order (create-card event lost or delayed); replaying old events after the group was archived/deleted; clock/date mismatch where the event's `date` lands on a day with no group; importing data from another environment.

Related errors


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