siyuan-note/siyuan · error
Conf.Language(132)
Error message
Conf.Language(132)
What it means
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.
Source
Thrown at kernel/model/search.go:629
}
boxIDs = gulu.Str.RemoveDuplicatedElem(boxIDs)
boxNames := Conf.BoxNames(boxIDs)
for _, b := range blocks {
name := boxNames[b.Box]
b.HPath = util.EscapeHTML(name) + b.HPath
}
}
func FindReplace(keyword, replacement string, replaceTypes map[string]bool, ids []string, paths, boxes []string, types, subTypes map[string]bool, method, orderBy, groupBy int) (err error) {
// orderBy 和 groupBy 仅用于兼容现有调用,替换目标不依赖搜索结果的展示顺序和分组方式。
return FindReplaceInBox(keyword, replacement, replaceTypes, ids, paths, boxes, types, subTypes, method, "")
}
// FindReplaceInBox 与 FindReplace 一致,但按 boxID 路由到加密 db 或全局 db。
func FindReplaceInBox(keyword, replacement string, replaceTypes map[string]bool, ids []string, paths, boxes []string, types, subTypes map[string]bool, method int, boxID string) (err error) {
// method:0:文本,1:查询语法,2:SQL,3:正则表达式
if 2 == method {
err = errors.New(Conf.Language(132))
return
}
if 1 == method {
// 将查询语法等价于关键字,因为 keyword 参数已经是结果关键字了
// Find and replace supports query syntax https://github.com/siyuan-note/siyuan/issues/14937
method = 0
}
// No longer trim spaces for the keyword and replacement https://github.com/siyuan-note/siyuan/issues/9229
if keyword == replacement {
return
}
r, _ := regexp.Compile(keyword)
escapedKey := util.EscapeHTML(keyword)
escapedKey = strings.ReplaceAll(escapedKey, """, """)
escapedKey = strings.ReplaceAll(escapedKey, "'", "'")View on GitHub (pinned to 251596fc0d)
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.
Example fix
// before
findReplace({ method: 2, keyword, replacement }) // -> error 132
// after
findReplace({ method: 0, keyword, replacement }) // keyword replace
// or: run SQL search -> get IDs -> replace with method:0 scoped by ids Defensive patterns
Strategy: validation
Validate before calling
// Go caller
const methodSQL = 2
if method == methodSQL {
return errors.New("SQL search does not support replace; use keyword or regex")
}
// or guard in JS before fetch
if (payload.method === 2) { throw new Error('SQL mode cannot replace'); } Type guard
// TypeScript const canReplace = (method: number): boolean => method !== 2;
Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12).
Data as JSON: /api/errors/8d40edcf7bf93069.
Report an issue: GitHub.