fix: 修复点击「重试失败条目」必然报错 Please enter a LIKE clause with bindings#87
Open
reoLantern wants to merge 1 commit into
Open
fix: 修复点击「重试失败条目」必然报错 Please enter a LIKE clause with bindings#87reoLantern wants to merge 1 commit into
Please enter a LIKE clause with bindings#87reoLantern wants to merge 1 commit into
Conversation
….sys.mjs validation Firefox's Sqlite.sys.mjs rejects LIKE clauses with inline string literals (regex: /\bLIKE\b\s(?![@:?])/i), throwing "Please enter a LIKE clause with bindings". This caused "重试失败条目" to always fail with an index error, while the same issue in getSuccessfullyIndexedItems was silently swallowed by a catch block in semanticIndexColumn.ts. Replace all four occurrences of LIKE 'failed:%' with LIKE ? and pass 'failed:%' as a bound parameter.
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR parameterizes SQL LIKE/NOT LIKE clauses that match the failed:% pattern in the vector store’s index-status queries.
Changes:
- Converted hard-coded
LIKE 'failed:%'/NOT LIKE 'failed:%'SQL to parameterized queries. - Updated deletion queries to bind the
failed:%pattern as a parameter (including the per-key delete path).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| // IMPORTANT: Single-line query to avoid Zotero queryAsync bug with multi-line SQL | ||
| const rows = await this.db.queryAsync(`SELECT item_key FROM index_status WHERE content_hash NOT LIKE 'failed:%'`); | ||
| const rows = await this.db.queryAsync(`SELECT item_key FROM index_status WHERE content_hash NOT LIKE ?`, ['failed:%']); |
|
|
||
| // IMPORTANT: Single-line query to avoid Zotero queryAsync bug with multi-line SQL | ||
| const rows = await this.db.queryAsync(`SELECT item_key FROM index_status WHERE content_hash LIKE 'failed:%'`); | ||
| const rows = await this.db.queryAsync(`SELECT item_key FROM index_status WHERE content_hash LIKE ?`, ['failed:%']); |
Comment on lines
+827
to
+830
| await this.db.queryAsync(`DELETE FROM index_status WHERE item_key = ? AND content_hash LIKE ?`, [key, 'failed:%']); | ||
| } | ||
| } else { | ||
| await this.db.queryAsync(`DELETE FROM index_status WHERE content_hash LIKE 'failed:%'`); | ||
| await this.db.queryAsync(`DELETE FROM index_status WHERE content_hash LIKE ?`, ['failed:%']); |
Comment on lines
825
to
831
| if (keys && keys.length > 0) { | ||
| for (const key of keys) { | ||
| await this.db.queryAsync(`DELETE FROM index_status WHERE item_key = ? AND content_hash LIKE 'failed:%'`, [key]); | ||
| await this.db.queryAsync(`DELETE FROM index_status WHERE item_key = ? AND content_hash LIKE ?`, [key, 'failed:%']); | ||
| } | ||
| } else { | ||
| await this.db.queryAsync(`DELETE FROM index_status WHERE content_hash LIKE 'failed:%'`); | ||
| await this.db.queryAsync(`DELETE FROM index_status WHERE content_hash LIKE ?`, ['failed:%']); | ||
| } |
|
已测试,可修复 |
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

问题现象
在语义搜索设置页点击 「重试失败条目」 按钮,界面立即弹出红色错误:
该错误与库中是否真的存在失败条目无关:
updateControlButtons中按status === 'idle'控制,preferences.xhtml里也没有默认隐藏),并非"构建失败后才出现的选项"。根因
错误来自 Firefox 内置的
toolkit/modules/Sqlite.sys.mjs(Zotero 作为 Gecko 应用复用该模块)。它在语句执行前用正则校验 SQL:LIKE之后若不是绑定占位符(@/:/?),直接抛错——此时尚未触碰数据库数据。vectorStore.ts中有 4 处查询使用了内联字符串字面量LIKE 'failed:%',会被上述正则拦截。触发链:点击按钮 →
SemanticSearchService.retryFailedItems()第一步调用vectorStore.getFailedItemKeys()→ 执行SELECT item_key FROM index_status WHERE content_hash LIKE 'failed:%'→ 在 SQL 校验阶段直接抛错 → 被preferenceScript.ts的 catch 捕获,以「索引错误: ...」形式显示。为何容易被忽视:同样的写法也存在于
getSuccessfullyIndexedItems()(用于语义索引列的对勾显示),但其调用方semanticIndexColumn.ts有try/catch将错误静默吞掉,用户看不到;只有retryFailedItems()的调用方未捕获,才把错误暴露到 UI。修复
将
vectorStore.ts中所有内联LIKE字面量改为参数绑定。绑定值中的%通配符语义不变,仅满足 Firefox 的校验要求,行为完全等价。getSuccessfullyIndexedItems... NOT LIKE 'failed:%'... NOT LIKE ?, 参数['failed:%']getFailedItemKeys... LIKE 'failed:%'... LIKE ?, 参数['failed:%']clearFailedMarkers(按 key)... item_key = ? AND content_hash LIKE 'failed:%',[key]... item_key = ? AND content_hash LIKE ?,[key, 'failed:%']clearFailedMarkers(清空全部)... LIKE 'failed:%'... LIKE ?, 参数['failed:%']复现与验证
复现(修复前):
索引错误: Error: Please enter a LIKE clause with bindings。验证(修复后):