{"record":{"id":"7509b40e56d5dd48","repo":"siyuan-note/siyuan","slug":"inline-style-name-must-not-be-empty","errorCode":null,"errorMessage":"inline style name must not be empty","messagePattern":"inline style name must not be empty","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/inline_style.go","lineNumber":673,"sourceCode":"\t\tif id == \"\" && generateIDs {\n\t\t\tfor {\n\t\t\t\tid = ast.NewNodeID()\n\t\t\t\tif _, exists := ids[id]; !exists {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif !ast.IsNodeIDPattern(id) {\n\t\t\treturn nil, fmt.Errorf(\"invalid inline style ID [%s]\", id)\n\t\t}\n\t\tif _, exists := ids[id]; exists {\n\t\t\treturn nil, fmt.Errorf(\"duplicate inline style ID [%s]\", id)\n\t\t}\n\t\tids[id] = struct{}{}\n\n\t\tname := strings.TrimSpace(style.Name)\n\t\tif name == \"\" {\n\t\t\treturn nil, errors.New(\"inline style name must not be empty\")\n\t\t}\n\t\tif maxInlineStyleNameRunes < utf8.RuneCountInString(name) {\n\t\t\treturn nil, fmt.Errorf(\"inline style name exceeds the %d character limit\", maxInlineStyleNameRunes)\n\t\t}\n\t\tif style.Light == nil || style.Dark == nil {\n\t\t\treturn nil, fmt.Errorf(\"inline style [%s] must define light and dark themes\", id)\n\t\t}\n\n\t\tlight, err := normalizeInlineStyleTheme(style.Light)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"invalid light theme of inline style [%s]: %w\", id, err)\n\t\t}\n\t\tdark, err := normalizeInlineStyleTheme(style.Dark)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"invalid dark theme of inline style [%s]: %w\", id, err)\n\t\t}\n\t\tlightColor, lightBackground := light.Color != \"\", light.BackgroundColor != \"\"\n\t\tdarkColor, darkBackground := dark.Color != \"\", dark.BackgroundColor != \"\"","sourceCodeStart":655,"sourceCodeEnd":691,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/model/inline_style.go#L655-L691","documentation":"After trimming, an inline style's Name must be a non-empty string: the name is what users see in the style picker, so nameless styles are rejected during normalization of the style list on save and load.","triggerScenarios":"setInlineStylesData receives an InlineStyle with Name \"\" or only whitespace; loadInlineStyles reads a config where a style entry has an empty name field.","commonSituations":"Programmatic style creation that sets only colors and forgets the name; a UI round-trip that cleared the name field; JSON entries created by hand missing the name key.","solutions":["Provide a non-empty, trimmed Name for every inline style before calling the set API.","Check for whitespace-only names client-side — the code trims first, so \"   \" still fails.","Fix the on-disk inline-styles JSON by filling in the missing name so loadInlineStyles succeeds."],"exampleFix":"// before\nstyle := &InlineStyle{ID: \"20240101120000-abcdefg\", Name: \"\", Light: &InlineStyleTheme{Color: \"#ff0000\"}, Dark: &InlineStyleTheme{Color: \"#ff0000\"}}\n// after\nstyle := &InlineStyle{ID: \"20240101120000-abcdefg\", Name: \"Red text\", Light: &InlineStyleTheme{Color: \"#ff0000\"}, Dark: &InlineStyleTheme{Color: \"#ff0000\"}}","handlingStrategy":"validation","validationCode":"for (const s of styles) { if (!s.Name || !s.Name.trim()) throw new Error(`style ${s.ID} has empty name`); }","typeGuard":"const hasName = (s: InlineStyle): boolean => typeof s.Name === 'string' && s.Name.trim().length > 0;","tryCatchPattern":"try { await saveStyles(styles) } catch (e) { if (/name must not be empty/.test(String(e))) { /* prompt for a name or drop the entry, then retry */ } }","preventionTips":["Require a name in any UI or script that creates styles","Trim names before saving","Validate the whole list before one bulk save — one bad entry fails the entire list"],"tags":["validation","empty-value","inline-styles"],"backgroundTag":"empty-required-field","analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}