{"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":"error","filePath":"kernel/model/search.go","lineNumber":629,"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":611,"sourceCodeEnd":647,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/model/search.go#L611-L647","documentation":"Thrown by FindReplaceInBox when the search method is SQL (method == 2). SQL search mode operates on raw SQL queries, so the kernel cannot map a single replacement string onto arbitrary result sets. Conf.Language(132) resolves to 'SQL search mode does not support the replace operation, please use another search method'. The check is an explicit guard at the top of FindReplaceInBox before any replacement logic runs.","triggerScenarios":"POST /api/search/findReplace (or the MCP/CLI equivalent) with a body where method=2 and a non-empty replacement string. Also reachable via FindReplace(...) which forwards method unchanged to FindReplaceInBox. Note method=1 (query syntax) is silently coerced to 0 (keyword) and does NOT throw.","commonSituations":"The UI lets the user pick 'SQL' from the search-method dropdown and then opens Find/Replace. A plugin or automation script reuses a SQL search payload for a replace call. The method integer is loaded from persisted search config that was last saved in SQL mode.","solutions":["Switch the search method to 0 (keyword), 1 (query syntax), or 3 (regex) before issuing the replace request.","If the caller must run SQL, perform the SQL search first to obtain IDs, then issue a keyword/regex replace scoped to those IDs.","Frontend: disable the 'Replace' button while the SQL method is selected so the request is never sent."],"exampleFix":"// before\nfindReplace({ method: 2, keyword, replacement }) // -> error 132\n// after\nfindReplace({ method: 0, keyword, replacement }) // keyword replace\n// or: run SQL search -> get IDs -> replace with method:0 scoped by ids","handlingStrategy":"validation","validationCode":"// Go caller\nconst methodSQL = 2\nif method == methodSQL {\n    return errors.New(\"SQL search does not support replace; use keyword or regex\")\n}\n// or guard in JS before fetch\nif (payload.method === 2) { throw new Error('SQL mode cannot replace'); }","typeGuard":"// TypeScript\nconst canReplace = (method: number): boolean => method !== 2;","tryCatchPattern":null,"preventionTips":["Treat method==2 as replace-incompatible at the call site, not just inside the kernel.","When reusing a saved search config for replace, force method to 0/1/3.","Disable the Replace affordance in the UI whenever SQL mode is active."],"tags":["search","find-replace","sql","i18n","kernel","validation"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}