{"record":{"id":"ed37349699fcb7e2","repo":"siyuan-note/siyuan","slug":"new-option-name-must-not-be-empty","errorCode":null,"errorMessage":"new option name must not be empty","messagePattern":"new option name must not be empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/attribute_view_key_config.go","lineNumber":243,"sourceCode":"\t}\n\tvar config struct {\n\t\tName    string  `json:\"name\"`\n\t\tNewName *string `json:\"newName\"`\n\t\tColor   *string `json:\"color\"`\n\t\tDesc    *string `json:\"desc\"`\n\t}\n\tif err := decodeAttributeViewKeyConfig(value, &config); nil != err {\n\t\treturn err\n\t}\n\toption := key.GetOption(config.Name)\n\tif nil == option {\n\t\treturn errors.New(\"optionUpdate must name an existing option\")\n\t}\n\tname, color, desc := option.Name, option.Color, option.Desc\n\tif nil != config.NewName {\n\t\tname = strings.TrimSpace(*config.NewName)\n\t\tif \"\" == name {\n\t\t\treturn errors.New(\"new option name must not be empty\")\n\t\t}\n\t\tif name != option.Name && nil != key.GetOption(name) {\n\t\t\treturn errors.New(\"new option name already exists\")\n\t\t}\n\t}\n\tif nil != config.Color {\n\t\tcolor = *config.Color\n\t\tif attrView.FilterColorValue(color) != color {\n\t\t\treturn errors.New(\"invalid option color\")\n\t\t}\n\t}\n\tif nil != config.Desc {\n\t\tdesc = *config.Desc\n\t}\n\tif name == option.Name {\n\t\top.Data = []*av.SelectOption{{Name: name, Color: color, Desc: desc}}\n\t\treturn updateAttributeViewColumnOptions(op)\n\t}","sourceCodeStart":225,"sourceCodeEnd":261,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/attribute_view_key_config.go#L225-L261","documentation":"When optionUpdate supplies newName, the resulting name must be non-empty after trimming, since names are the identity of select options. An explicitly provided but blank newName is rejected instead of being silently ignored.","triggerScenarios":"Calling UpdateAttributeViewKeyConfig with setting \"optionUpdate\" and data {name: \"Existing\", newName: \"\"} or newName of only whitespace.","commonSituations":"UI clearing the rename input then submitting; code that always includes newName and sends the empty string when untouched (should omit the field or send null instead).","solutions":["Omit newName (or send null) when the name should not change — only a non-null string triggers rename validation","Provide a non-empty trimmed newName","Validate the new name in the UI before submitting"],"exampleFix":"// before\n{avID, keyID, setting: \"optionUpdate\", data: {name: \"Todo\", newName: \"\"}}\n// after\n{avID, keyID, setting: \"optionUpdate\", data: {name: \"Todo\", color: \"2\"}}","handlingStrategy":"validation","validationCode":"if (newName !== undefined && newName !== null && newName.trim() === \"\") {\n  throw new Error(\"blank newName: omit the field to keep the name\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Omit newName instead of sending an empty string when the name is unchanged","Enforce non-empty rename inputs in the UI before submitting"],"tags":["attribute-view","select-options","validation"],"backgroundTag":"empty-required-field","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}