hcengineering/platform · error
Card not found, _id: ${ref}
Error message
Card not found, _id: ${ref} What it means
getCardTitle resolves a Card by ref (or accepts a preloaded doc). If no doc is passed and findOne finds no Card with that _id in the workspace, it cannot compute a title and throws with the missing ref.
Source
Thrown at plugins/card-resources/src/utils.ts:462
}
if (special === 'cards') {
return base
}
const client = getClient()
const object = await client.findOne(card.class.Card, { _id: special as Ref<Card> })
if (object === undefined) {
return base
}
return { name: object.title }
}
export async function getCardTitle (client: TxOperations, ref: Ref<Card>, doc?: Card): Promise<string> {
const object = doc ?? (await client.findOne(card.class.Card, { _id: ref }))
if (object === undefined) throw new Error(`Card not found, _id: ${ref}`)
const h = client.getHierarchy()
const attrs = [...h.getAllAttributes(object._class, core.class.Doc).values()].sort((a, b) => {
const rankA = a.rank ?? toRank(a._id) ?? ''
const rankB = b.rank ?? toRank(b._id) ?? ''
return rankA.localeCompare(rankB)
})
const res: string[] = []
for (const attr of attrs) {
const val = (object as any)[attr.name]
if (attr.showInPresenter === true && val !== undefined) {
if (typeof val === 'string' || typeof val === 'number') {
res.push(val.toString())
} else if (typeof val === 'boolean') {
res.push(val ? '✅' : '❌️')
}
}
}
View on GitHub (pinned to 63e28dc964)
Solutions
- Verify the card ref exists in this workspace before calling, or pass the already-loaded doc
- Handle deletion: skip title lookup for refs whose card no longer exists
- Use findOne yourself and render a fallback label like 'Deleted card' when undefined
Example fix
// before
const title = await getCardTitle(client, ref) // throws if deleted
// after
const doc = await client.findOne(card.class.Card, { _id: ref })
const title = doc !== undefined ? await getCardTitle(client, ref, doc) : 'Deleted card' Defensive patterns
Strategy: validation
Validate before calling
const doc = docArg ?? await client.findOne(card.class.Card, { _id: ref })
if (doc === undefined) return 'Deleted card' // fallback instead of calling getCardTitle Type guard
const cardExists = async (client: TxOperations, ref: Ref<Card>): Promise<boolean> =>
(await client.findOne(card.class.Card, { _id: ref })) !== undefined Try / catch
try {
title = await getCardTitle(client, ref)
} catch (err) {
if ((err as Error).message.startsWith('Card not found')) {
title = 'Deleted card'
} else throw err
} Prevention
- Pass the already-loaded Card as the doc argument whenever available
- Clean up references (notifications, attachments) when a card is deleted
- Render fallback titles for stale refs in UI listings
When it happens
Trigger: Calling getCardTitle with a Ref<Card> that no longer exists (deleted card), an id from another workspace, a stale reference cached in a UI, or a typo'd ref — without supplying the optional doc argument.
Common situations: Notifications/attachments referencing cards deleted afterward; cross-workspace data copy; rendering card titles from cached refs after data cleanup; race where card is deleted between listing and title fetch.
Related errors
- Reference not found
- Issue status not found: ${name}
- sequence object not found
- Cannot create card with base type ${type}
- sequence object not found
AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29).
Data as JSON: /api/errors/9072e55d71f40c3b.
Report an issue: GitHub.