siyuan-note/siyuan · warning

Conf.Language(151)

Error message

Conf.Language(151)

What it means

The TagSnapshot function rejects a tag name that fails the gulu.File.IsValidFilename check, meaning it contains characters invalid for filesystem filenames (e.g., path separators, null bytes, or OS-reserved names on Windows like CON, PRN). The Language(151) string is the 'invalid filename' message. This guard fires after the empty-name check.

Source

Thrown at kernel/model/repository.go:1653

	err = repo.RemoveTag(tag)
	return
}

func TagSnapshot(id, name string) (err error) {
	if 1 > len(Conf.Repo.Key) {
		err = errors.New(Conf.Language(26))
		return
	}

	name = util.RemoveInvalid(name)
	name = strings.TrimSpace(name)
	if "" == name {
		err = errors.New(Conf.Language(142))
		return
	}

	if !gulu.File.IsValidFilename(name) {
		err = errors.New(Conf.Language(151))
		return
	}

	repo, err := newRepository()
	if err != nil {
		return
	}

	index, err := repo.GetIndex(id)
	if err != nil {
		return
	}

	if err = repo.AddTag(index.ID, name); err != nil {
		msg := fmt.Sprintf("Add tag to data snapshot [%s] failed: %s", index.ID, err)
		util.PushStatusBar(msg)
		return
	}

View on GitHub (pinned to 251596fc0d)

Solutions

  1. Remove or replace invalid filename characters from the tag name before calling TagSnapshot
  2. Use alphanumeric characters, hyphens, and underscores as a safe naming convention
  3. Run the name through gulu.File.IsValidFilename on the client side before submitting

Example fix

// before
model.TagSnapshot(id, "feature/v2:final")

// after
name = strings.Map(func(r rune) rune {
    if gulu.File.IsValidFilename(string(r)) {
        return r
    }
    return '-'
}, name)
model.TagSnapshot(id, name)
Defensive patterns

Strategy: validation

Validate before calling

// Validate filename before calling TagSnapshot
if !gulu.File.IsValidFilename(name) {
    return errors.New("tag name contains invalid characters")
}

Type guard

// Check if a string is a valid filename for tagging
func isValidTagName(name string) bool {
    name = strings.TrimSpace(name)
    if name == "" {
        return false
    }
    return gulu.File.IsValidFilename(name)
}

Prevention

When it happens

Trigger: Calling TagSnapshot(id, name) where the name contains characters like forward slashes, backslashes, colons, asterisks, question marks, angle brackets, pipe characters, or is a reserved filename on the target OS. The gulu.File.IsValidFilename function performs platform-aware validation.

Common situations: A user includes special characters in a tag name (e.g., 'feature/v2', 'backup:2024', 'Q&A'). On Windows, names like 'CON' or 'LPT1' are reserved. This is common when tag names are auto-generated from content that includes punctuation.

Related errors


AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12). Data as JSON: /api/errors/97994a7f456ebac9. Report an issue: GitHub.