{"record":{"id":"dbaea746d46f6e27","repo":"siyuan-note/siyuan","slug":"conf-language-16","errorCode":null,"errorMessage":"Conf.Language(16)","messagePattern":"Conf\\.Language\\(16\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/file.go","lineNumber":2288,"sourceCode":"func validateCreateDoc(boxID, p, title string, titleEmpty bool) (ret *createDocValidation, err error) {\n\tp = normalizeBoxDocPath(boxID, p)\n\ttitle = normalizeDocTitle(title)\n\tif 512 < utf8.RuneCountInString(title) {\n\t\t// 限制笔记本名和文档名最大长度为 `512` https://github.com/siyuan-note/siyuan/issues/6299\n\t\treturn nil, errors.New(Conf.Language(106))\n\t}\n\n\tisEmpty := false\n\tif \"\" == title {\n\t\ttitle = Conf.Language(16)\n\t\tisEmpty = true\n\t} else if titleEmpty {\n\t\tisEmpty = true\n\t}\n\n\tbaseName := strings.TrimSpace(path.Base(p))\n\tif \"\" == util.GetTreeID(baseName) {\n\t\treturn nil, errors.New(Conf.Language(16))\n\t}\n\tif strings.HasPrefix(baseName, \".\") {\n\t\treturn nil, errors.New(Conf.Language(13))\n\t}\n\n\tbox, boxErr := getOpenedBox(boxID)\n\tif nil != boxErr {\n\t\treturn nil, boxErr\n\t}\n\n\tfolder := path.Dir(p)\n\thPath := \"/\" + title\n\tif \"/\" != folder {\n\t\tparentID := path.Base(folder)\n\t\tparentTree, loadErr := LoadTreeByBlockID(parentID)\n\t\tif nil != loadErr {\n\t\t\tlogging.LogErrorf(\"get parent tree [%s] failed\", parentID)\n\t\t\treturn nil, ErrBlockNotFound","sourceCodeStart":2270,"sourceCodeEnd":2306,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/model/file.go#L2270-L2306","documentation":"In validateCreateDoc, after the title defaults to the localized 'Untitled' (key 16) when empty, the kernel validates the target path: it takes path.Base(p) and runs util.GetTreeID(baseName). If the base name does not contain a valid tree ID (the trailing 14-hex-digit timestamp-id suffix), the path cannot map to a document, so it returns errors.New(Conf.Language(16)). Here key 16's text ('Untitled') is repurposed as a generic invalid-doc-path message.","triggerScenarios":"POST /api/filetree/createDocWithMd (or createDoc) where the path's base segment lacks a valid block/document ID suffix — e.g. path '/foo' or '/foo-bar' without '-20230801...' ID, or an empty/malformed baseName.","commonSituations":"Scripts that build the path from a human-readable name only instead of 'name-YYYYMMDDhhmmss-xx' format (e.g. via /api/filetree/getID or generateDocID); plugins copying paths between notebooks without re-issuing IDs; hand-edited paths with lost ID suffixes.","solutions":["Generate a valid doc path first by calling /api/filetree/getID (or create docs via createDocWithMd using paths issued by the API)","Append a proper ID in the form '<name>-YYYYMMDDhhmmss' plus check suffix to the path base","Use the frontend's idgen/utility so the base name contains a valid tree ID","Pass an existing parent path plus title and let the kernel compose the child path"],"exampleFix":"// before\nawait fetchPost('/api/filetree/createDocWithMd', {notebook, path: '/My Note', markdown});\n// after\nconst id = await fetchPost('/api/filetree/getID', {}); // returns e.g. '20230815102030-abc1234'\nawait fetchPost('/api/filetree/createDocWithMd', {notebook, path: '/My Note-' + id, markdown});","handlingStrategy":"validation","validationCode":"function hasValidTreeID(baseName) {\n  // base must end with '-YYYYMMDDhhmmss-xxxxxx' style ID; empty GetTreeID means invalid\n  return /-\\d{14}-[0-9a-f]{7}$/i.test(baseName);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await fetchPost('/api/filetree/createDocWithMd', {notebook, path, markdown});\n} catch (e) {\n  if (String(e).includes('Untitled')) {\n    // regenerate path with a fresh ID and retry\n  }\n}","preventionTips":["Never hand-build doc paths without an ID suffix; use /api/filetree/getID","Create docs via title+parent APIs rather than raw paths when possible","Validate the path format in a helper before every create call"],"tags":["siyuan","kernel","create-doc","invalid-path","doc-id"],"backgroundTag":"invalid-identifier-format","analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}