chatboxai/chatbox · error
Session references an unknown resource: ${resourceId}
Error message
Session references an unknown resource: ${resourceId} What it means
Thrown when a session lists a resourceId that does not exist in manifest.resources. Every resource referenced by a session must be present, so dangling references are rejected.
Source
Thrown at src/renderer/packages/backup/types.ts:132
if (ownSessionIds.has(sessionId)) throw new Error(`Resource contains a duplicate session id: ${resource.id}`)
ownSessionIds.add(sessionId)
if (!sessionIds.has(sessionId)) throw new Error(`Resource references an unknown session: ${sessionId}`)
}
if (resource.scope === 'session' && resource.sessionIds.length !== 1) {
throw new Error(`Session-scoped resource must reference exactly one session: ${resource.id}`)
}
if (resource.scope === 'global' && resource.sessionIds.length !== 0) {
throw new Error(`Global resource must not reference a session: ${resource.id}`)
}
}
const resourcesById = new Map(manifest.resources.map((resource) => [resource.id, resource]))
const sessionsById = new Map(manifest.sessions.map((session) => [session.id, session]))
for (const session of manifest.sessions) {
const ownResourceIds = new Set<string>()
for (const resourceId of session.resourceIds) {
if (ownResourceIds.has(resourceId)) throw new Error(`Session contains a duplicate resource id: ${session.id}`)
ownResourceIds.add(resourceId)
if (!resourceIds.has(resourceId)) throw new Error(`Session references an unknown resource: ${resourceId}`)
if (!resourcesById.get(resourceId)?.sessionIds.includes(session.id)) {
throw new Error(`Session/resource mapping is inconsistent: ${session.id}/${resourceId}`)
}
}
}
for (const resource of manifest.resources) {
for (const sessionId of resource.sessionIds) {
const session = sessionsById.get(sessionId)
if (!session?.resourceIds.includes(resource.id)) {
throw new Error(`Resource/session mapping is inconsistent: ${resource.id}/${sessionId}`)
}
}
}
if (
manifest.stats.sessionCount !== manifest.sessions.length ||
manifest.stats.resourceCount !== manifest.resources.length ||
manifest.stats.warningCount !== manifest.warnings.length
) {View on GitHub (pinned to 81571269ad)
Solutions
- Add the missing resource entry.
- Remove the dangling resourceId from the session.
- Re-export sessions and resources together.
Example fix
// before
// session references a resource not in manifest.resources
// after
const ids = new Set(manifest.resources.map((r) => r.id))
for (const s of manifest.sessions) {
s.resourceIds = s.resourceIds.filter((id) => ids.has(id))
} Defensive patterns
Strategy: try-catch
Validate before calling
function findDanglingResourceRefs(manifest: BackupManifest): string[] {
const ids = new Set(manifest.resources.map((r) => r.id))
const dups = new Set<string>()
for (const s of manifest.sessions) for (const rid of s.resourceIds) if (!ids.has(rid)) dups.add(rid)
return [...dups]
} Try / catch
try {
validateBackupManifestGraph(manifest)
} catch (error) {
if (/references an unknown resource/.test((error as Error).message)) pruneDanglingResourceRefs(manifest)
throw error
} Prevention
- Always export resources and their sessions together.
- When deleting a resource, remove it from every session's resourceIds.
- Normalize id casing/whitespace before packing the manifest.
When it happens
Trigger: session.resourceIds contains an id not present among the manifest.resources ids.
Common situations: A resource was deleted but the session still references it; a partial export; an id mismatch (casing/trim).
Related errors
- Resource references an unknown session: ${sessionId}
- Session/resource mapping is inconsistent: ${session.id}/${re
- Resource/session mapping is inconsistent: ${resource.id}/${s
- Manifest contains a duplicate path: ${descriptor.path}
- Session id does not match manifest: ${descriptor.path}
AI-assisted analysis of chatboxai/chatbox@81571269ad (2026-08-12).
Data as JSON: /api/errors/6f272137d037db43.
Report an issue: GitHub.