siyuan-note/siyuan · error

Conf.Language(142)

Error message

Conf.Language(142)

What it means

SetCriterion rejects a criterion whose Name field is empty with Conf.Language(142) = 'Input can not be empty'. A saved search criterion (filter layout) must be named so it can be listed and re-selected later. The check runs before the criteria mutex is taken and before merging into the stored list.

Source

Thrown at kernel/model/storage.go:199

	U                 bool `json:"u"`
	DocTitle          bool `json:"docTitle"`
	CodeBlock         bool `json:"codeBlock"`
	MathBlock         bool `json:"mathBlock"`
	HtmlBlock         bool `json:"htmlBlock"`
}

var criteriaLock = sync.Mutex{}

func GetCriteria() (ret []*Criterion) {
	criteriaLock.Lock()
	defer criteriaLock.Unlock()
	ret, _ = getCriteria()
	return
}

func SetCriterion(criterion *Criterion) (err error) {
	if "" == criterion.Name {
		return errors.New(Conf.Language(142))
	}

	criteriaLock.Lock()
	defer criteriaLock.Unlock()

	criteria, err := getCriteria()
	if err != nil {
		return
	}

	update := false
	for i, c := range criteria {
		if c.Name == criterion.Name {
			criteria[i] = criterion
			update = true
			break
		}
	}

View on GitHub (pinned to 251596fc0d)

Solutions

  1. Require a non-empty name in the save-criteria form before enabling the Save button.
  2. On the caller side, set a default name (e.g. 'Criterion ' + timestamp) if the user left it blank.
  3. Validate name != '' before calling SetCriterion and surface a localized field error.

Example fix

// before
SetCriterion(&Criterion{Name: "", ...}) // -> error 142
// after
name := strings.TrimSpace(c.Name)
if name == "" { name = "Untitled Criterion" }
SetCriterion(&Criterion{Name: name, ...})
Defensive patterns

Strategy: validation

Validate before calling

// Go caller
if criterion == nil || strings.TrimSpace(criterion.Name) == "" {
    return errors.New("criterion name is required")
}

Type guard

// Go
func hasCriterionName(c *Criterion) bool { return c != nil && strings.TrimSpace(c.Name) != "" }

Prevention

When it happens

Trigger: POST /api/storage/setCriterion (and the search-criteria save flow) with a criterion JSON whose name is "" or missing. Reproduces when the user saves a filter layout without typing a name, or a script posts a criterion struct with an uninitialized Name field.

Common situations: User clicks Save on the filter panel with an empty name field. A plugin imports criterion JSON that omits the name key. Frontend form validation was skipped.

Related errors


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