Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:bug: Ignore missing blocks in index requests https://github.com/siyuan-note/siyuan/issues/19171

Daniel3bab90d680d2
diff --git a/kernel/api/block.go b/kernel/api/block.go
index 7d02f9ad8c..ed038af179 100644
--- a/kernel/api/block.go
+++ b/kernel/api/block.go
@@ -1121,7 +1121,7 @@ func getBlockIndex(c *gin.Context) {
id := arg["id"].(string)
boxID := encryptedNotebookFromArg(arg)
- if !holdBlockRequest(c, ret, boxID, arg) {
+ if !holdBlockRequest(c, ret, boxID, arg, true) {
return
}
if !isBlockPublishAccessible(c, id, boxID) {
diff --git a/kernel/api/block_test.go b/kernel/api/block_test.go
index ecaa32366e..09936d0544 100644
--- a/kernel/api/block_test.go
+++ b/kernel/api/block_test.go
@@ -365,6 +365,10 @@ func TestBlockPublishAccessGuards(t *testing.T) {
if response["code"].(float64) != 0 || response["data"].(map[string]any)["stat"].(map[string]any)["blockCount"].(float64) != 0 {
t.Fatalf("missing blocks should be ignored by word count without an API error: %v", response)
}
+ response = blockGuardRequest(model.RoleAdministrator, `{"id":"`+missingID+`"}`, getBlockIndex)
+ if response["code"].(float64) != 0 || response["data"].(float64) != 0 {
+ t.Fatalf("missing block should report a zero index without an API error: %v", response)
+ }
})
}