{"record":{"id":"c1dc5b227b139a89","repo":"siyuan-note/siyuan","slug":"conf-language-142-c1dc5b","errorCode":null,"errorMessage":"Conf.Language(142)","messagePattern":"Conf\\.Language\\(142\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/storage.go","lineNumber":199,"sourceCode":"\tU                 bool `json:\"u\"`\n\tDocTitle          bool `json:\"docTitle\"`\n\tCodeBlock         bool `json:\"codeBlock\"`\n\tMathBlock         bool `json:\"mathBlock\"`\n\tHtmlBlock         bool `json:\"htmlBlock\"`\n}\n\nvar criteriaLock = sync.Mutex{}\n\nfunc GetCriteria() (ret []*Criterion) {\n\tcriteriaLock.Lock()\n\tdefer criteriaLock.Unlock()\n\tret, _ = getCriteria()\n\treturn\n}\n\nfunc SetCriterion(criterion *Criterion) (err error) {\n\tif \"\" == criterion.Name {\n\t\treturn errors.New(Conf.Language(142))\n\t}\n\n\tcriteriaLock.Lock()\n\tdefer criteriaLock.Unlock()\n\n\tcriteria, err := getCriteria()\n\tif err != nil {\n\t\treturn\n\t}\n\n\tupdate := false\n\tfor i, c := range criteria {\n\t\tif c.Name == criterion.Name {\n\t\t\tcriteria[i] = criterion\n\t\t\tupdate = true\n\t\t\tbreak\n\t\t}\n\t}","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/model/storage.go#L181-L217","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Require a non-empty name in the save-criteria form before enabling the Save button.","On the caller side, set a default name (e.g. 'Criterion ' + timestamp) if the user left it blank.","Validate name != '' before calling SetCriterion and surface a localized field error."],"exampleFix":"// before\nSetCriterion(&Criterion{Name: \"\", ...}) // -> error 142\n// after\nname := strings.TrimSpace(c.Name)\nif name == \"\" { name = \"Untitled Criterion\" }\nSetCriterion(&Criterion{Name: name, ...})","handlingStrategy":"validation","validationCode":"// Go caller\nif criterion == nil || strings.TrimSpace(criterion.Name) == \"\" {\n    return errors.New(\"criterion name is required\")\n}","typeGuard":"// Go\nfunc hasCriterionName(c *Criterion) bool { return c != nil && strings.TrimSpace(c.Name) != \"\" }","tryCatchPattern":null,"preventionTips":["Frontend: make the Name input required and disable Save when empty.","Trim whitespace before validation; do not accept a name of only spaces.","Round-trip test criterion JSON to catch omitted-name regressions."],"tags":["criterion","search-filter","validation","i18n","kernel"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}