{"record":{"id":"872b7c8dd38bc2c9","repo":"siyuan-note/siyuan","slug":"response-msg-util","errorCode":null,"errorMessage":"response.msg","messagePattern":"response\\.msg","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/src/block/util.ts","lineNumber":49,"sourceCode":"    previousID?: string,\n    parentID?: string,\n    fallbackParentID?: string,\n    resolveMissingPosition?: boolean,\n    excludedChildIDs?: Set<string>,\n    childReplacements?: Map<string, ISuperBlockChildReplacement>,\n}) => {\n    const id = nodeElement.getAttribute(\"data-node-id\");\n    const visibleChildElements = Array.from(nodeElement.children).filter(item =>\n        item.hasAttribute(\"data-node-id\") && !options.excludedChildIDs?.has(item.getAttribute(\"data-node-id\")));\n    let operationChildElements = visibleChildElements;\n    if (visibleChildElements.some(item => item.getAttribute(\"data-type\") === \"NodeHeading\" &&\n        item.getAttribute(\"fold\") === \"1\")) {\n        const response = await fetchSyncPost(\"/api/block/getBlockDOM\", {\n            id,\n            notebook: options.notebookID,\n        });\n        if (response.code !== 0) {\n            throw new Error(response.msg);\n        }\n        const template = document.createElement(\"template\");\n        template.innerHTML = normalizeHTMLAssetIFrameBlockDOM(response.data?.dom || \"\");\n        const fullSuperBlockElement = template.content.querySelector(`[data-node-id=\"${id}\"]`);\n        if (!fullSuperBlockElement) {\n            return {\n                doOperations: [] as IOperation[],\n                undoOperations: [] as IOperation[],\n                childIDs: [] as string[],\n                foldedHeadingIDs: [] as string[],\n                previousId: options.previousID\n            };\n        }\n        operationChildElements = Array.from(fullSuperBlockElement.children).filter(item =>\n            item.hasAttribute(\"data-node-id\") && !options.excludedChildIDs?.has(item.getAttribute(\"data-node-id\")));\n    }\n    const {childIDs, foldedHeadingIDs} = resolveCancelSuperBlockChildren(operationChildElements.map(item => ({\n        id: item.getAttribute(\"data-node-id\"),","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/app/src/block/util.ts#L31-L67","documentation":"getCancelSBOperations fetches the full superblock DOM via /api/block/getBlockDOM when a fold state requires it. If the kernel responds with a non-zero code, the raw `response.msg` (a server-localized error string) is thrown so callers/UI see the kernel's failure reason.","triggerScenarios":"Calling operationData/getCancelSBOperations with a block id that does not exist in the notebook, or when the kernel fails to serve getBlockDOM (notebook closed, index not ready, DB locked).","commonSituations":"Stale references to deleted blocks after sync; operating on a block whose notebook was closed; kernel indexing still in progress right after startup.","solutions":["Verify the block id exists (search in the app or query /api/block/getBlockDOM directly)","Wait for kernel indexing to complete and retry","Rebuild the index (Settings - Rebuild index) if getBlockDOM fails for many blocks","Check kernel logs for the underlying SQL/index error behind response.msg"],"exampleFix":"// before\nif (response.code !== 0) {\n    throw new Error(response.msg);\n}\n// after: give callers context about which block failed\nif (response.code !== 0) {\n    throw new Error(`getBlockDOM failed for block ${id}: ${response.msg}`);\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"const isApiOk = (res: {code: number}): boolean => res.code === 0;","tryCatchPattern":"try {\n    await operationData(options);\n} catch (e) {\n    showMessage(e.message); // kernel msg, e.g. block not found; refresh and retry\n}","preventionTips":["Refresh documents after sync so block ids are current","Do not operate on blocks from closed notebooks","Wait for kernel indexing to finish before bulk operations"],"tags":["kernel-api","blocks","api-error"],"backgroundTag":"api-error-response","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"}