{"record":{"id":"773afa2d70305ac4","repo":"siyuan-note/siyuan","slug":"conf-language-331","errorCode":null,"errorMessage":"Conf.Language(331)","messagePattern":"Conf\\.Language\\(331\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"info","filePath":"kernel/model/import_obsidian.go","lineNumber":295,"sourceCode":"\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()\n\t}\n\tfinishObsidianTaskLocked(task, ObsidianTaskStateCancelled, \"Import cancelled\", \"\")\n\tret := snapshotObsidianTask(task)\n\tobsidianTasksMu.Unlock()\n\tremoveObsidianTemp(taskID)\n\treturn ret, nil\n}\n\nfunc StartObsidianVaultImport(taskID, notebookName string) (*ObsidianVaultTask, error) {\n\tobsidianTasksMu.Lock()\n\ttask := obsidianTasks[taskID]\n\tif task == nil || task.State != ObsidianTaskStateReady || task.Context == nil {\n\t\tobsidianTasksMu.Unlock()\n\t\treturn nil, errors.New(Conf.Language(332))\n\t}","sourceCodeStart":277,"sourceCodeEnd":313,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/import_obsidian.go#L277-L313","documentation":"CancelObsidianVaultTask returns this error when the task exists but its State is not cancellable (e.g. already running past a checkpoint, completed, failed, or cancelled). The task snapshot is still returned so the caller can inspect the current state. i18n string 331 is \"The Obsidian Vault import task can no longer be cancelled\".","triggerScenarios":"Calling cancel on a task whose isObsidianCancellableState(task.State) is false — typically a task that already reached ObsidianTaskStateCancelled/Completed/Failed, or one in a terminal phase of import.","commonSituations":"Double-clicking a cancel button; racing another client that already cancelled; cancelling after the import finished successfully.","solutions":["Check the returned task snapshot's State before attempting cancellation; skip if terminal","Disable the cancel UI action once the task reports a non-cancellable state","Retry cancellation immediately after starting the task only if you truly need a pre-emptive cancel, otherwise avoid the race"],"exampleFix":"// before\nawait cancelObsidianImport(taskID); // errors if already done\n// after\nconst { data: task } = await getObsidianTask(taskID);\nif (CANCELLABLE_STATES.includes(task.state)) {\n  await cancelObsidianImport(taskID);\n}","handlingStrategy":"type-guard","validationCode":"const CANCELLABLE = ['analyzing', 'importing'];\nif (!CANCELLABLE.includes(task.state)) return snapshotOnly(task);","typeGuard":"function isCancellable(t) { return t && typeof t.state === 'string' && ['analyzing','importing'].includes(t.state); }","tryCatchPattern":"try { await cancelObsidianImport(taskID); } catch (e) { const snap = extractTaskSnapshot(e); if (snap) updateUiState(snap.state); }","preventionTips":["Poll the task state and disable the Cancel button on terminal states","Debounce cancel clicks to avoid duplicate concurrent cancels"],"tags":["obsidian","import","invalid-state-transition","race-condition"],"backgroundTag":"invalid-state-transition","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}