Skip to content

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

:bug: Fix insertBlock API argument check https://ld246.com/article/1711525429788

Daniel24c59dd09568
diff --git a/kernel/api/block_op.go b/kernel/api/block_op.go
index 051e03ae5a..829c266a00 100644
--- a/kernel/api/block_op.go
+++ b/kernel/api/block_op.go
@@ -222,13 +222,13 @@ func moveBlock(c *gin.Context) {
var parentID, previousID string
if nil != arg["parentID"] {
parentID = arg["parentID"].(string)
- if util.InvalidIDPattern(parentID, ret) {
+ if "" != parentID && util.InvalidIDPattern(parentID, ret) {
return
}
}
if nil != arg["previousID"] {
previousID = arg["previousID"].(string)
- if util.InvalidIDPattern(previousID, ret) {
+ if "" != previousID && util.InvalidIDPattern(previousID, ret) {
return
}
@@ -364,26 +364,20 @@ func insertBlock(c *gin.Context) {
var parentID, previousID, nextID string
if nil != arg["parentID"] {
parentID = arg["parentID"].(string)
- if "" != parentID {
- if util.InvalidIDPattern(parentID, ret) {
- return
- }
+ if "" != parentID && util.InvalidIDPattern(parentID, ret) {
+ return
}
}
if nil != arg["previousID"] {
previousID = arg["previousID"].(string)
- if "" != previousID {
- if util.InvalidIDPattern(previousID, ret) {
- return
- }
+ if "" != previousID && util.InvalidIDPattern(parentID, ret) {
+ return
}
}
if nil != arg["nextID"] {
nextID = arg["nextID"].(string)
- if "" != nextID {
- if util.InvalidIDPattern(nextID, ret) {
- return
- }
+ if "" != nextID && util.InvalidIDPattern(parentID, ret) {
+ return
}
}