siyuan-note/siyuan · error

response.msg

Error message

response.msg

What it means

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.

Solutions

  1. Verify the block id exists (search in the app or query /api/block/getBlockDOM directly)
  2. Wait for kernel indexing to complete and retry
  3. Rebuild the index (Settings - Rebuild index) if getBlockDOM fails for many blocks
  4. Check kernel logs for the underlying SQL/index error behind response.msg

Example fix

// before
if (response.code !== 0) {
    throw new Error(response.msg);
}
// after: give callers context about which block failed
if (response.code !== 0) {
    throw new Error(`getBlockDOM failed for block ${id}: ${response.msg}`);
}
Defensive patterns

Strategy: try-catch

Type guard

const isApiOk = (res: {code: number}): boolean => res.code === 0;

Try / catch

try {
    await operationData(options);
} catch (e) {
    showMessage(e.message); // kernel msg, e.g. block not found; refresh and retry
}

Prevention

When it happens

Trigger: 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).

Common situations: Stale references to deleted blocks after sync; operating on a block whose notebook was closed; kernel indexing still in progress right after startup.

Related errors


AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19). Data as JSON: /api/errors/872b7c8dd38bc2c9. Report an issue: GitHub.

Appendix: source

Thrown at app/src/block/util.ts:49

    previousID?: string,
    parentID?: string,
    fallbackParentID?: string,
    resolveMissingPosition?: boolean,
    excludedChildIDs?: Set<string>,
    childReplacements?: Map<string, ISuperBlockChildReplacement>,
}) => {
    const id = nodeElement.getAttribute("data-node-id");
    const visibleChildElements = Array.from(nodeElement.children).filter(item =>
        item.hasAttribute("data-node-id") && !options.excludedChildIDs?.has(item.getAttribute("data-node-id")));
    let operationChildElements = visibleChildElements;
    if (visibleChildElements.some(item => item.getAttribute("data-type") === "NodeHeading" &&
        item.getAttribute("fold") === "1")) {
        const response = await fetchSyncPost("/api/block/getBlockDOM", {
            id,
            notebook: options.notebookID,
        });
        if (response.code !== 0) {
            throw new Error(response.msg);
        }
        const template = document.createElement("template");
        template.innerHTML = normalizeHTMLAssetIFrameBlockDOM(response.data?.dom || "");
        const fullSuperBlockElement = template.content.querySelector(`[data-node-id="${id}"]`);
        if (!fullSuperBlockElement) {
            return {
                doOperations: [] as IOperation[],
                undoOperations: [] as IOperation[],
                childIDs: [] as string[],
                foldedHeadingIDs: [] as string[],
                previousId: options.previousID
            };
        }
        operationChildElements = Array.from(fullSuperBlockElement.children).filter(item =>
            item.hasAttribute("data-node-id") && !options.excludedChildIDs?.has(item.getAttribute("data-node-id")));
    }
    const {childIDs, foldedHeadingIDs} = resolveCancelSuperBlockChildren(operationChildElements.map(item => ({
        id: item.getAttribute("data-node-id"),

View on GitHub (pinned to 9f775e8a12)