{"record":{"id":"82c2092732c30dea","repo":"siyuan-note/siyuan","slug":"the-obsidian-vault-import-task-was-not-found-or-ha","errorCode":null,"errorMessage":"The Obsidian Vault import task was not found or has expired","messagePattern":"The Obsidian Vault import task was not found or has expired","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"kernel/model/import_obsidian.go","lineNumber":280,"sourceCode":"\ttask := &obsidianTask{TaskID: taskID, State: ObsidianTaskStateQueued, Message: \"Waiting to analyze\", Cancel: cancel}\n\tobsidianTasks[taskID] = task\n\tobsidianActive = taskID\n\tret := snapshotObsidianTask(task)\n\tobsidianTasksMu.Unlock()\n\n\tif replacedTaskID != \"\" {\n\t\tremoveObsidianTemp(replacedTaskID)\n\t}\n\tgo analyzeObsidianVaultTask(ctx, taskID, localPath)\n\treturn ret, nil\n}\n\nfunc GetObsidianVaultTask(taskID string) (*ObsidianVaultTask, error) {\n\tobsidianTasksMu.Lock()\n\tdefer obsidianTasksMu.Unlock()\n\ttask := obsidianTasks[taskID]\n\tif task == nil {\n\t\treturn nil, errors.New(Conf.Language(330))\n\t}\n\treturn snapshotObsidianTask(task), nil\n}\n\nfunc CancelObsidianVaultTask(taskID string) (*ObsidianVaultTask, error) {\n\tobsidianTasksMu.Lock()\n\ttask := obsidianTasks[taskID]\n\tif task == nil {\n\t\tobsidianTasksMu.Unlock()\n\t\treturn nil, errors.New(Conf.Language(330))\n\t}\n\tif !isObsidianCancellableState(task.State) {\n\t\tret := snapshotObsidianTask(task)\n\t\tobsidianTasksMu.Unlock()\n\t\treturn ret, errors.New(Conf.Language(331))\n\t}\n\tif task.Cancel != nil {\n\t\ttask.Cancel()","sourceCodeStart":262,"sourceCodeEnd":298,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/model/import_obsidian.go#L262-L298","documentation":"Returned by GetObsidianVaultTask (i18n key 330) when no task exists in the in-memory obsidianTasks map for the given taskID. Tasks are deleted after obsidianResultTTL (10 minutes) following a terminal state, and analysis tasks are deleted after obsidianReadyTTL expiry. A taskID that never existed or has been reaped produces this error.","triggerScenarios":"POST /api/import/getObsidianVaultTask with a taskID that is nil/empty in the map (line 278-280). Occurs when polling a task more than 10 minutes after it finished, polling a fabricated/typo'd ID, or polling after a server restart cleared the in-memory map.","commonSituations":"The UI retains a stale taskID across a page reload or kernel restart; more than 10 minutes elapsed since the task completed; the taskID was mistyped or truncated in transit; the analysis expired and was reaped.","solutions":["If the task was reaped after completion, start a fresh analysis with startObsidianVaultAnalysis.","Verify the taskID matches the value returned by the original startObsidianVaultAnalysis or startObsidianVaultImport call.","Poll more frequently than the 10-minute result TTL to avoid missing the terminal state.","Handle this error in the UI by resetting to the import-entry screen rather than looping."],"exampleFix":"// before\nresp, _ := post(\"/api/import/getObsidianVaultTask\", {taskID: staleID})\n// -> { code: -1, msg: \"The Obsidian Vault import task was not found or has expired\" }\n\n// after: treat not-found/expired as 'start over'\nif resp.code !== 0 {\n    showImportEntryScreen() // user re-selects vault and starts fresh\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"task, err := model.GetObsidianVaultTask(taskID)\nif err != nil {\n    if err.Error() == Conf.Language(330) {\n        // task reaped or unknown — reset to import entry, do not loop\n        return nil, ErrTaskGone\n    }\n    return nil, err\n}","preventionTips":["Poll getObsidianVaultTask at intervals shorter than the 10-minute result TTL.","Treat a not-found result as 'start over' rather than retrying the same ID.","Store the taskID returned by startObsidianVaultAnalysis and validate it before polling."],"tags":["obsidian","import","task-lifecycle","not-found","expiry"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}