{"record":{"id":"8d40edcf7bf93069","repo":"siyuan-note/siyuan","slug":"conf-language-132","errorCode":null,"errorMessage":"Conf.Language(132)","messagePattern":"Conf\\.Language\\(132\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"kernel/model/search.go","lineNumber":636,"sourceCode":"\t}\n\tboxIDs = gulu.Str.RemoveDuplicatedElem(boxIDs)\n\tboxNames := Conf.BoxNames(boxIDs)\n\tfor _, b := range blocks {\n\t\tname := boxNames[b.Box]\n\t\tb.HPath = util.EscapeHTML(name) + b.HPath\n\t}\n}\n\nfunc FindReplace(keyword, replacement string, replaceTypes map[string]bool, ids []string, paths, boxes []string, types, subTypes map[string]bool, method, orderBy, groupBy int) (err error) {\n\t// orderBy 和 groupBy 仅用于兼容现有调用，替换目标不依赖搜索结果的展示顺序和分组方式。\n\treturn FindReplaceInBox(keyword, replacement, replaceTypes, ids, paths, boxes, types, subTypes, method, \"\")\n}\n\n// FindReplaceInBox 与 FindReplace 一致，但按 boxID 路由到加密 db 或全局 db。\nfunc FindReplaceInBox(keyword, replacement string, replaceTypes map[string]bool, ids []string, paths, boxes []string, types, subTypes map[string]bool, method int, boxID string) (err error) {\n\t// method：0：文本，1：查询语法，2：SQL，3：正则表达式\n\tif 2 == method {\n\t\terr = errors.New(Conf.Language(132))\n\t\treturn\n\t}\n\n\tif 1 == method {\n\t\t// 将查询语法等价于关键字，因为 keyword 参数已经是结果关键字了\n\t\t// Find and replace supports query syntax https://github.com/siyuan-note/siyuan/issues/14937\n\t\tmethod = 0\n\t}\n\n\t// No longer trim spaces for the keyword and replacement https://github.com/siyuan-note/siyuan/issues/9229\n\tif keyword == replacement {\n\t\treturn\n\t}\n\n\tr, _ := regexp.Compile(keyword)\n\tescapedKey := util.EscapeHTML(keyword)\n\tescapedKey = strings.ReplaceAll(escapedKey, \"&#34;\", \"&quot;\")\n\tescapedKey = strings.ReplaceAll(escapedKey, \"&#39;\", \"'\")","sourceCodeStart":618,"sourceCodeEnd":654,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/model/search.go#L618-L654","documentation":"FindReplaceInBox rejects replace operations whose method is 2 (SQL). Executing arbitrary SQL while replacing text would replace matched block content unreliably and unsafely, so the kernel refuses up front with the localized message Conf.Language(132) (\"Replace is not supported for SQL queries\").","triggerScenarios":"Calling FindReplaceInBox(..., method=2, ...) — i.e. the search dialog is in SQL mode and the user pressed replace-all; kernel callers findReplace/FindReplace forward the UI's current method value.","commonSituations":"A user runs a search in SQL query mode in the Replace tab and clicks Replace All; an automation script copies the search method parameter (2) into a replace call.","solutions":["Switch the search dialog to text, query-syntax, or regex mode (method 0/1/3) before replacing","For SQL-driven bulk edits, write a transaction that updates the target blocks via the block update API instead of using replace","If scripting, pass method=3 (regex) to achieve SQL-like precision over block content"],"exampleFix":"// before\nFindReplace(keyword, repl, types, subTypes, 2 /* SQL */, ids, paths, boxes)\n// after\nFindReplace(keyword, repl, types, subTypes, 3 /* regex or 0=text */, ids, paths, boxes)","handlingStrategy":"validation","validationCode":"// Reject SQL mode before invoking replace\nif method == 2 {\n    return errors.New(\"replace is not supported in SQL search mode; use method 0/1/3\")\n}","typeGuard":"// TS caller: const canReplace = (m: number) => [0, 1, 3].includes(m);","tryCatchPattern":"err := FindReplace(keyword, repl, types, subTypes, method, ids, paths, boxes)\nif err != nil && err.Error() == Conf.Language(132) {\n    // notify user to switch from SQL mode\n}","preventionTips":["Disable the replace action in the UI when search mode is SQL","Map query-syntax (method 1) to keyword replace as the kernel does","Prefer regex mode (method 3) for precise programmatic replacement"],"tags":["find-replace","unsupported-method","search"],"backgroundTag":"unsupported-operation","analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}