chatboxai/chatbox · error
Resource references an unknown session: ${sessionId}
Error message
Resource references an unknown session: ${sessionId} What it means
Thrown when a resource lists a sessionId that does not correspond to any session in manifest.sessions. Every session referenced by a resource must exist, so dangling references are rejected.
Source
Thrown at src/renderer/packages/backup/types.ts:116
if (sessionIds.has(session.id)) throw new Error(`Duplicate session id in manifest: ${session.id}`)
sessionIds.add(session.id)
if (session.meta.id !== session.id) throw new Error(`Session metadata id does not match: ${session.id}`)
}
for (const resource of manifest.resources) {
if (resourceIds.has(resource.id)) throw new Error(`Duplicate resource id in manifest: ${resource.id}`)
resourceIds.add(resource.id)
const ownResourceKeys = new Set<string>()
for (const key of resource.originalStorageKeys) {
if (ownResourceKeys.has(key)) throw new Error(`Resource contains a duplicate storage key: ${resource.id}`)
ownResourceKeys.add(key)
if (resourceKeys.has(key)) throw new Error(`Duplicate resource storage key in manifest: ${key}`)
resourceKeys.add(key)
}
const ownSessionIds = new Set<string>()
for (const sessionId of resource.sessionIds) {
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}`)View on GitHub (pinned to 81571269ad)
Solutions
- Add the missing session entry to manifest.sessions.
- Remove the dangling sessionId from the resource.
- Re-export sessions and resources together.
Example fix
// before
// resource references a session not in manifest.sessions
// after
const ids = new Set(manifest.sessions.map((s) => s.id))
for (const r of manifest.resources) {
r.sessionIds = r.sessionIds.filter((id) => ids.has(id))
} Defensive patterns
Strategy: try-catch
Validate before calling
function findDanglingSessionRefs(manifest: BackupManifest): string[] {
const ids = new Set(manifest.sessions.map((s) => s.id))
const dups = new Set<string>()
for (const r of manifest.resources) for (const sid of r.sessionIds) if (!ids.has(sid)) dups.add(sid)
return [...dups]
} Try / catch
try {
validateBackupManifestGraph(manifest)
} catch (error) {
if (/references an unknown session/.test((error as Error).message)) pruneDanglingSessionRefs(manifest)
throw error
} Prevention
- Always export sessions and their resources together.
- When deleting a session, remove it from every resource's sessionIds.
- Normalize id casing/whitespace before packing the manifest.
When it happens
Trigger: resource.sessionIds contains an id not present among the manifest.sessions ids.
Common situations: A session was deleted after resources were attached; a partial export that included resources but not their sessions; mismatched id casing.
Related errors
- Session references an unknown resource: ${resourceId}
- 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/27ba4b6d1fb63613.
Report an issue: GitHub.