chatboxai/chatbox · error
Session/resource mapping is inconsistent: ${session.id}/${re
Error message
Session/resource mapping is inconsistent: ${session.id}/${resourceId} What it means
Thrown for a forward-link mismatch: session S lists resource R, but R.sessionIds does not include S. The session-to-resource and resource-to-session edges must be symmetric.
Source
Thrown at src/renderer/packages/backup/types.ts:134
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
) {
throw new Error('Backup manifest statistics do not match its entries')
}View on GitHub (pinned to 81571269ad)
Solutions
- Make the links bidirectional: ensure each resource lists the sessions that reference it and vice versa.
- Re-export so the exporter writes both directions.
- Repair by adding session.id to the resource's sessionIds.
Example fix
// before
// session->resource link exists, but resource->session does not
// after
const resourcesById = new Map(manifest.resources.map((r) => [r.id, r]))
for (const s of manifest.sessions) {
for (const rid of s.resourceIds) {
const r = resourcesById.get(rid)
if (r && !r.sessionIds.includes(s.id)) r.sessionIds.push(s.id)
}
} Defensive patterns
Strategy: try-catch
Validate before calling
function forwardLinksAreSymmetric(manifest: BackupManifest): boolean {
const resourcesById = new Map(manifest.resources.map((r) => [r.id, r]))
return manifest.sessions.every((s) =>
s.resourceIds.every((rid) => resourcesById.get(rid)?.sessionIds.includes(s.id))
)
} Try / catch
try {
validateBackupManifestGraph(manifest)
} catch (error) {
if (/Session\/resource mapping is inconsistent/.test((error as Error).message)) symmetrizeLinks(manifest)
throw error
} Prevention
- Write both directions of every link in the same exporter code path.
- Re-validate after any link edit on either side.
- Avoid manual manifest edits; regenerate instead.
When it happens
Trigger: resourcesById.get(resourceId).sessionIds does not include session.id, even though session.resourceIds includes resourceId.
Common situations: One side of a bidirectional link was edited without the other; exporter wrote resourceIds but forgot sessionIds; a merge that updated only one direction.
Related errors
- Resource references an unknown session: ${sessionId}
- Session references an unknown resource: ${resourceId}
- 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/23c24820f0ed00d9.
Report an issue: GitHub.