{"record":{"id":"9461f7bb6c78ea4d","repo":"siyuan-note/siyuan","slug":"unsupported-block-operation-s","errorCode":null,"errorMessage":"unsupported block operation [%s]","messagePattern":"unsupported block operation \\[(.+?)\\]","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/block_operation.go","lineNumber":52,"sourceCode":"\t\t\tif err = treenode.CheckContainerParent(operation.ParentID); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t}\n\tcase \"delete\":\n\t\t// 外部删除请求必须命中现存节点，编辑器内部仍可使用幂等删除。\n\t\ttree, loadErr := LoadTreeByBlockID(operation.ID)\n\t\tif loadErr != nil {\n\t\t\treturn nil, loadErr\n\t\t}\n\t\tnode := treenode.GetNodeInTree(tree, operation.ID)\n\t\tif node == nil {\n\t\t\treturn nil, fmt.Errorf(\"block not found [%s]\", operation.ID)\n\t\t}\n\t\tif node == tree.Root {\n\t\t\treturn nil, fmt.Errorf(\"document cannot be deleted as a block [%s]\", operation.ID)\n\t\t}\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"unsupported block operation [%s]\", operation.Action)\n\t}\n\n\ttx := &Transaction{DoOperations: []*Operation{operation}}\n\tif err = performTxSyncLocked(tx); err != nil {\n\t\treturn nil, err\n\t}\n\treturn []*Transaction{tx}, nil\n}\n","sourceCodeStart":34,"sourceCodeEnd":61,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/block_operation.go#L34-L61","documentation":"PerformBlockOperation returns \"unsupported block operation [%s]\" when the operation's Action falls into the default case of its switch — i.e. an action name the kernel does not implement. Only explicitly supported actions (such as \"delete\") reach the transaction stage.","triggerScenarios":"Passing an Action string that is not one of the supported values to the block operation API — typos like \"Delete\", \"remove\", or actions copied from another API's vocabulary.","commonSituations":"Plugin/API clients written against a newer or different API spec; hand-written automation scripts guessing action names; version drift where a client expects an action this kernel build does not support.","solutions":["Use exactly the supported action name (e.g. \"delete\" — lowercase, no variants).","Check the server's API docs / handler source for the list of supported actions for your kernel version.","Update the plugin/API client if it targets a different SiYuan version's action set.","Validate the action string against a whitelist before sending."],"exampleFix":"// before\nawait fetchPost('/api/block/performBlockOperation', { operations: [{ action: 'remove', id }] });\n// after\nawait fetchPost('/api/block/performBlockOperation', { operations: [{ action: 'delete', id }] });","handlingStrategy":"validation","validationCode":"const SUPPORTED_ACTIONS = ['delete'];\nfunction assertSupportedAction(action) {\n  if (!SUPPORTED_ACTIONS.includes(action)) throw new Error(`unsupported action: ${action}`);\n}","typeGuard":null,"tryCatchPattern":"try { await performBlockOperation(action, id); } catch (e) { if (String(e.msg).includes('unsupported block operation')) console.error(`bad action '${action}'; see API docs for supported values`); throw e; }","preventionTips":["Keep an explicit whitelist of supported action strings in client code.","Pin plugin code to a documented SiYuan kernel version and re-check actions on upgrade.","Use exact lowercase action names from docs/API.md."],"tags":["unsupported-operation","api","invalid-enum","kernel"],"backgroundTag":"unsupported-operation","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"}