{"record":{"id":"cf06356717991a01","repo":"siyuan-note/siyuan","slug":"invalid-reorder-position-s","errorCode":null,"errorMessage":"invalid reorder position [%s]","messagePattern":"invalid reorder position \\[(.+?)\\]","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/file.go","lineNumber":2746,"sourceCode":"\t\tfileTreeSortLock.Unlock()\n\t\treturn ret, writeErr\n\t}\n\tfileTreeSortLock.Unlock()\n\n\tret.Changed = true\n\tret.Notebook = box.ID\n\tret.ParentPath = parentPath\n\tIncSync()\n\tpushFiletreeSortChanged(sortIDs)\n\treturn\n}\n\nfunc validateReorderArgs(sourceIDs []string, targetID, position string) error {\n\tif 1 > len(sourceIDs) {\n\t\treturn errors.New(\"source IDs must not be empty\")\n\t}\n\tif \"before\" != position && \"after\" != position {\n\t\treturn fmt.Errorf(\"invalid reorder position [%s]\", position)\n\t}\n\tseen := map[string]struct{}{}\n\tfor _, sourceID := range sourceIDs {\n\t\tif sourceID == targetID {\n\t\t\treturn fmt.Errorf(\"target ID [%s] must not be included in source IDs\", targetID)\n\t\t}\n\t\tif _, ok := seen[sourceID]; ok {\n\t\t\treturn fmt.Errorf(\"duplicate source ID [%s]\", sourceID)\n\t\t}\n\t\tseen[sourceID] = struct{}{}\n\t}\n\treturn nil\n}\n\nfunc isSortableDocument(tree *treenode.BlockTree) bool {\n\treturn nil != tree && tree.ID == tree.RootID && \"d\" == tree.Type && !IsBoxDoc(tree.BoxID, tree.RootID)\n}\n","sourceCodeStart":2728,"sourceCodeEnd":2764,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/file.go#L2728-L2764","documentation":"The position argument of a document reorder must be exactly the string \"before\" or \"after\", indicating whether sources are placed before or after the target document. Any other string is rejected with this formatted error. The comparison is case-sensitive.","triggerScenarios":"Passing \"Before\", \"top\", \"above\", or a localized string as position; sending position as a number or enum instead of the literal strings; typo like \"befor\".","commonSituations":"Plugins mapping their own drop-zone labels to position values without normalizing; API scripts guessing the parameter vocabulary; UI code using \"before\"/\"after\" only in some branches.","solutions":["Send only the literal lowercase strings \"before\" or \"after\"","Normalize/whitelist the position value at the call site before invoking the API","Check the API documentation for the exact parameter contract and update the caller","Map any other positioning concepts (e.g. 'inside', 'first') to the supported move APIs instead"],"exampleFix":"// before\nreorderDocs(ids, targetID, dropZone) // e.g. \"above\"\n// after\nconst pos = dropZone === \"above\" ? \"before\" : \"after\"\nreorderDocs(ids, targetID, pos)","handlingStrategy":"validation","validationCode":"if (position !== \"before\" && position !== \"after\") throw new Error(`position must be \"before\"|\"after\", got ${position}`)","typeGuard":"const isReorderPosition = (p) => p === \"before\" || p === \"after\"","tryCatchPattern":"try { await api.reorderDocs(src, targetID, pos) } catch (e) { if (String(e).includes(\"invalid reorder position\")) { pos = pos.toLowerCase() === \"before\" ? \"before\" : \"after\"; return retryOnce() } throw e }","preventionTips":["Centralize the position value in a union type/constant set (\"before\" | \"after\")","Normalize drop-zone labels to the API vocabulary at the boundary","Never pass user-visible or localized strings as API position values"],"tags":["go","kernel","validation","argument"],"backgroundTag":"invalid-enum-value","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}