siyuan-note/siyuan · error

Input can not be empty

Error message

Input can not be empty

What it means

TagSnapshot validates the user-supplied tag name: after removing invalid characters (util.RemoveInvalid) and trimming spaces, an empty string yields errors.New(Conf.Language(142)) ('Input can not be empty'). The check exists because an empty tag name cannot identify a snapshot tag in the encrypted index.

Solutions

  1. Pass a non-empty tag name containing letters/digits to TagSnapshot
  2. Sanitize the input yourself before calling: strip invalid characters, trim, and reject empty results client-side with a clear prompt
  3. If the desired name collapses to empty after sanitization, choose a different name — do not retry with the same value
  4. Check Conf.Language(142) text in the error to distinguish this validation failure from the repo-key (Language 26) and symbol (Language 151) errors

Example fix

// before
name := docTitle // may be "---" or "   "
model.TagSnapshot(id, name)
// after
name := util.RemoveInvalid(docTitle)
name = strings.TrimSpace(name)
if name == "" {
    return errors.New("snapshot tag name can not be empty")
}
model.TagSnapshot(id, name)
Defensive patterns

Strategy: validation

Validate before calling

function validateTagName(raw) {
  const name = raw.replace(/[\\/:*?"'<>|]/g, '').trim();
  if (!name) throw new Error('Snapshot tag name can not be empty');
  return name;
}

Try / catch

try {
    await fetchPost('/api/repo/tagSnapshot', {id, name});
} catch (e) {
    if (e.msg === 'Input can not be empty') focusNameInputWithPrompt();
}

Prevention

When it happens

Trigger: Calling TagSnapshot with a name consisting only of characters stripped by util.RemoveInvalid (e.g. symbols, path separators) or only whitespace, so the sanitized name becomes "" and the Language 142 error is returned.

Common situations: Frontend submits an empty tag input; automation passes a name built from a title that is entirely punctuation; whitespace-only name from a form that only trim-checks client-side after the kernel already stripped symbols.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19). Data as JSON: /api/errors/4117c031e12b43df. Report an issue: GitHub.

Appendix: source

Thrown at kernel/model/repository.go:1728

		return
	}

	err = repo.RemoveTag(tag)
	return
}

func TagSnapshot(id, name string) (err error) {
	assetDownloadSourceMu.RLock()
	defer assetDownloadSourceMu.RUnlock()
	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 := newRepositoryWithAssetSourceLocked()
	if err != nil {
		return
	}

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

View on GitHub (pinned to 9f775e8a12)