siyuan-note/siyuan · error
Conf.Language(151)
Error message
Conf.Language(151)
What it means
The new asset name supplied to the rename API is not a valid filename according to gulu.File.IsValidFilename, so the kernel rejects it with a localized message (Conf.Language(151)). This guards against names containing path separators, reserved characters, or OS-illegal characters that could corrupt the assets tree.
Solutions
- Provide a new name without path separators or reserved characters (letters, digits, spaces, hyphens, underscore, CJK text are fine)
- Trim whitespace and remove illegal characters before calling the rename API
- Sanitize with the same rules as util.FilterUploadFileName in scripts/plugins
- If renaming to add an extension only, keep the base name valid — the kernel re-appends the original extension automatically
Example fix
// before
renameAsset('assets/old.png', 'chart: 2024/07.png')
// after
renameAsset('assets/old.png', 'chart 2024-07.png') Defensive patterns
Strategy: validation
Validate before calling
const INVALID = /[\\/:*?"<>|]/;
function isValidAssetName(n) {
return typeof n === 'string' && n.trim().length > 0 && !INVALID.test(n) &&
!/^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])$/i.test(n.trim());
} Type guard
function isSafeFilename(v) {
return typeof v === 'string' && v.length > 0 && v.length < 255 && !/[\\/:*?"<>|]/.test(v);
} Try / catch
if (!isSafeFilename(newName)) { showInvalidNameHint(); return; }
try { await renameAsset(oldPath, newName) } catch (e) {
if (e.message === Conf.Language(151)) showInvalidNameHint();
} Prevention
- Sanitize names with the same rules as util.FilterUploadFileName
- Reject path separators and Windows-reserved names in your UI before submitting
- Preserve the original extension; the kernel appends it automatically
When it happens
Trigger: Calling model.RenameAsset with newName that is empty-after-trim pass but fails IsValidFilename — e.g. contains '/' or '\\', characters like ':' '*' '?' '"' '<' '>' '|', leading/trailing dots, reserved Windows names (CON, NUL), or is too long.
Common situations: Pasting a filename copied from a URL or note text that includes slashes or illegal characters; renaming an asset to a Windows-reserved device name; automation scripts generating names without sanitization; localized UI message shown to end user.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- Conf.Language(151) (localized invalid filename message)
- asset path does not belong to a notebook
- asset path escapes data directory
- asset path is required
- asset path must be a file
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/2572d358b21d368c.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/assets.go:1669
// 加密笔记本的资源磁盘文件名参与 AAD,重命名需要重新封装密文,当前不支持。
if absPath, absErr := GetAssetAbsPathInBox(oldPath, ""); absErr == nil {
if IsEncryptedAssetPath(absPath) {
err = errors.New("renaming assets in encrypted notebooks is not supported")
return
}
}
newName = strings.TrimSpace(newName)
newName = util.FilterUploadFileName(newName)
if path.Base(oldCleanPath) == newName {
return
}
if "" == newName {
return
}
if !gulu.File.IsValidFilename(newName) {
err = errors.New(Conf.Language(151))
return
}
newName = util.AssetName(newName+filepath.Ext(oldCleanPath), ast.NewNodeID())
parentDir := path.Dir(oldCleanPath)
newPath = path.Join(parentDir, newName)
oldAbsPath, getErr := GetAssetAbsPathInBox(oldPath, "")
if getErr != nil {
logging.LogErrorf("get asset [%s] abs path failed: %s", oldPath, getErr)
return
}
if err = ensureReadableAssetLocal(oldAbsPath); err != nil {
return
}
newAbsPath := filepath.Join(filepath.Dir(oldAbsPath), newName)
filelock.Lock(oldAbsPath)
if err = os.Rename(oldAbsPath, newAbsPath); err != nil {
if err = gulu.File.Copy(oldAbsPath, newAbsPath); err != nil {View on GitHub (pinned to 9f775e8a12)