siyuan-note/siyuan · error
Cannot create a file starting with .
Error message
Cannot create a file starting with .
What it means
The very next guard in validateCreateDoc (kernel/model/file.go:2328): after the basename yields a valid tree ID, it must not start with '.' — dot-prefixed files are hidden/config files in the notebook directory (like .siyuan/), so creating a document named ".<something>.sy" is rejected with Conf.Language(13) ("Cannot create a file starting with .").
Solutions
- Remove the leading dot from the filename: use "20240101120000-abcd123.sy" style names
- Sanitize external filenames in import pipelines (strip leading dots before building the create path)
- Keep hidden-file conventions out of data/<box>/ — the kernel reserves dot-entries for its own metadata
Example fix
// before
fetchPost('/api/filetree/createDocWithMd', {notebook, path: `/.${id}.sy`, markdown})
// after
fetchPost('/api/filetree/createDocWithMd', {notebook, path: `/${id}.sy`, markdown}) Defensive patterns
Strategy: validation
Validate before calling
base := strings.TrimSpace(path.Base(p))
if strings.HasPrefix(base, ".") {
return fmt.Errorf("document filename must not start with '.': %s", base)
} Type guard
func hasNoLeadingDot(p string) bool { return !strings.HasPrefix(strings.TrimSpace(path.Base(p)), ".") } Prevention
- Strip leading dots during import sanitization, before path construction
- Reserve dot-prefixed entries for kernel metadata (.siyuan/ etc.) in data/<box>/
- Combine this check with the tree-ID check in one path validator
When it happens
Trigger: POST /api/filetree/createDoc / createDocWithMd with path whose filename component begins with a dot, e.g. "/.draft-20240101......sy" or "/parent/.20240101120000-abcd123.sy" (the ID passed the previous check but the leading dot fails this one).
Common situations: Unix-minded users naming files .draft.sy; sanitizers that prefix temp names with '.'; importers preserving dotfiles found in a source folder.
Related errors
AI-assisted analysis of siyuan-note/siyuan@afa823b6b4 (2026-08-18).
Data as JSON: /api/errors/dc9e6edd4755d3b9.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/file.go:2328
if 512 < utf8.RuneCountInString(title) {
// 限制笔记本名和文档名最大长度为 `512` https://github.com/siyuan-note/siyuan/issues/6299
return nil, errors.New(Conf.Language(106))
}
isEmpty := false
if "" == title {
title = Conf.Language(16)
isEmpty = true
} else if titleEmpty {
isEmpty = true
}
baseName := strings.TrimSpace(path.Base(p))
if "" == util.GetTreeID(baseName) {
return nil, errors.New(Conf.Language(16))
}
if strings.HasPrefix(baseName, ".") {
return nil, errors.New(Conf.Language(13))
}
box, boxErr := getOpenedBox(boxID)
if nil != boxErr {
return nil, boxErr
}
folder := path.Dir(p)
hPath := "/" + title
if "/" != folder {
parentID := path.Base(folder)
parentTree, loadErr := LoadTreeByBlockID(parentID)
if nil != loadErr {
logging.LogErrorf("get parent tree [%s] failed", parentID)
return nil, ErrBlockNotFound
}
parentPath := strings.TrimSuffix(parentTree.Path, ".sy")
if parentTree.Box != boxID || cleanBoxDocDir(parentPath) != cleanBoxDocDir(folder) {View on GitHub (pinned to afa823b6b4)