agalwood/Motrix · error · Error
Invalid Task Inspector Activity snapshot
Error message
Invalid Task Inspector Activity snapshot
What it means
Thrown as a plain Error (not an AppError, no ErrorCode) when the reader returned a snapshot for the taskId but parseTaskInspectorActivitySnapshot(result, taskId) returned a falsy value — the stored data could not be parsed into a valid Task Inspector Activity snapshot. Indicates data-shape corruption rather than a missing task.
Source
Thrown at src/core/inspector-activity/task-inspector-activity-query.ts:67
return invalid()
}
let taskId: string
try {
taskId = assertTaskId(descriptor.value as string)
} catch {
return invalid()
}
queryCount += 1
if (options.failAfterFirstQuery && queryCount > 1) {
throw new Error('deterministic Task Inspector Activity query failure')
}
const result = reader.snapshot(taskId)
if (result == null) {
throw new AppError(ErrorCode.TaskNotFound, `Task not found: ${taskId}`)
}
const snapshot = parseTaskInspectorActivitySnapshot(result, taskId)
if (!snapshot) {
throw new Error('Invalid Task Inspector Activity snapshot')
}
return snapshot
},
}
}
View on GitHub (pinned to 1a708ee577)
Solutions
- Reset or rebuild the activity store for the affected task to clear the malformed record.
- Ensure you are on a version whose snapshot schema matches the stored data (run migrations).
- Log the raw result to identify which field failed parsing.
- Restore the activity log from a backup if available.
Example fix
// before
const snapshot = parseTaskInspectorActivitySnapshot(result, taskId)
if (!snapshot) {
throw new Error('Invalid Task Inspector Activity snapshot')
}
// after — narrow and surface which field failed
const snapshot = parseTaskInspectorActivitySnapshot(result, taskId)
if (!snapshot) {
log.warn('unparseable activity record for task %s: %j', taskId, result)
throw new Error(`Invalid Task Inspector Activity snapshot for task ${taskId}`)
} Defensive patterns
Strategy: try-catch
Validate before calling
// Schema-check the raw record before parsing.
function isRawActivityRecord(v: unknown): v is Record<string, unknown> {
return typeof v === 'object' && v !== null && 'events' in v && Array.isArray((v as any).events)
} Type guard
function isRawActivityRecord(v: unknown): v is { events: unknown[]; [k: string]: unknown } {
return typeof v === 'object' && v !== null && Array.isArray((v as { events?: unknown[] }).events)
} Try / catch
try {
return query.snapshot({ taskId })
} catch (err) {
if (err instanceof Error && /Invalid Task Inspector Activity snapshot/.test(err.message)) {
// reset/rebuild the activity store for this task
await activityStore.rebuild(taskId)
return null
}
throw err
} Prevention
- Run schema migrations on every version upgrade.
- Treat the activity log as append-only to avoid corruption.
- Validate records at write time, not just read time.
- Back up the activity store before migrations.
When it happens
Trigger: parseTaskInspectorActivitySnapshot(result, taskId) returns null/undefined/false after reader.snapshot returned a non-null value. The raw record exists but does not conform to the expected snapshot schema.
Common situations: On-disk activity log written by an older/newer incompatible version; schema migration was skipped; partial/corrupted write of the activity record; a hand-edited or externally-modified store.
Related errors
- TaskNotFound
- PluginManifestInvalid
- PluginRuntimeFault
- inherited_schema_missing
- canonical_task_columns_missing
AI-assisted analysis of agalwood/Motrix@1a708ee577 (2026-08-12).
Data as JSON: /api/errors/be8b083ea4f5392e.
Report an issue: GitHub.