{"record":{"id":"84be919df67c076b","repo":"siyuan-note/siyuan","slug":"field-name-must-not-be-empty-attribute-view-key-config","errorCode":null,"errorMessage":"field name must not be empty","messagePattern":"field name must not be empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/attribute_view_key_config.go","lineNumber":52,"sourceCode":"\t\treturn err\n\t}\n\tkey, err := attrView.GetKey(keyID)\n\tif nil != err {\n\t\treturn err\n\t}\n\top := &Operation{AvID: avID, ID: keyID, Typ: string(key.Type), Name: key.Name}\n\tfor setting, value := range config {\n\t\tswitch setting {\n\t\tcase \"name\", \"type\", \"icon\", \"desc\", \"numberFormat\", \"dateFormat\", \"template\", \"renderTemplate\":\n\t\t\ttext, ok := value.(string)\n\t\t\tif !ok {\n\t\t\t\treturn fmt.Errorf(\"%s must be a string\", setting)\n\t\t\t}\n\t\t\top.Data, op.Format = text, text\n\t\t\tswitch setting {\n\t\t\tcase \"name\":\n\t\t\t\tif \"\" == strings.TrimSpace(text) {\n\t\t\t\t\treturn errors.New(\"field name must not be empty\")\n\t\t\t\t}\n\t\t\t\top.Name = text\n\t\t\t\treturn updateAttributeViewColumn(op)\n\t\t\tcase \"type\":\n\t\t\t\tif _, err = newAttributeViewKey(keyID, key.Name, text, key.Icon, key.DateFormat); nil != err {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\top.Typ = text\n\t\t\t\treturn updateAttributeViewColumn(op)\n\t\t\tcase \"icon\":\n\t\t\t\treturn setAttributeViewColIcon(op)\n\t\t\tcase \"desc\":\n\t\t\t\treturn setAttributeViewColDesc(op)\n\t\t\tcase \"numberFormat\":\n\t\t\t\tif av.KeyTypeNumber != key.Type || !slices.Contains(AttributeViewKeyNumberFormats, text) {\n\t\t\t\t\treturn errors.New(\"numberFormat requires a number field and a supported format\")\n\t\t\t\t}\n\t\t\t\treturn updateAttributeViewColNumberFormat(op)","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/attribute_view_key_config.go#L34-L70","documentation":"When updating the \"name\" setting of a database field, the new name must contain at least one non-whitespace character. A blank or whitespace-only name is rejected because a field must always have a usable display name.","triggerScenarios":"Calling UpdateAttributeViewKeyConfig with {\"name\": \"\"} or {\"name\": \"   \"} via the databaseKeyUpdate path.","commonSituations":"UI forms submitted without filling the name; a 'clear the title' script using an empty string; trimming logic stripping the intended name away before send.","solutions":["Provide a non-empty name, e.g. {\"name\": \"Due Date\"}","Trim-check the value client-side: if name.trim() === '' skip or prompt instead of sending","If the intent was to remove the field, use the delete-column operation instead of renaming to empty"],"exampleFix":"// before\n{\"name\": \"   \"}\n// after\n{\"name\": \"Due Date\"}","handlingStrategy":"validation","validationCode":"function assertNonEmptyName(name) { if (typeof name !== 'string' || name.trim() === '') throw new Error('field name must not be empty'); }","typeGuard":null,"tryCatchPattern":"try { await updateKeyConfig(avID, keyID, { name }); } catch (e) { if (/name must not be empty/.test(e.message)) { showNamePrompt(); } else throw e; }","preventionTips":["Require the name input in UI forms before submit","Trim and check emptiness before API calls","Use the delete-column operation rather than renaming to empty"],"tags":["api","validation","empty-value","attribute-view"],"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"}