{"record":{"id":"48de3d8c54f49ad7","repo":"siyuan-note/siyuan","slug":"inline-style-name-exceeds-the-d-character-limit","errorCode":null,"errorMessage":"inline style name exceeds the %d character limit","messagePattern":"inline style name exceeds the (.+?) character limit","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/inline_style.go","lineNumber":676,"sourceCode":"\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 != \"\"\n\t\tif !lightColor && !lightBackground {\n\t\t\treturn nil, fmt.Errorf(\"inline style [%s] must define color or backgroundColor\", id)\n\t\t}","sourceCodeStart":658,"sourceCodeEnd":694,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/model/inline_style.go#L658-L694","documentation":"Inline style names are limited to maxInlineStyleNameRunes (64) Unicode runes. The check counts runes (not bytes), so multibyte characters count once each; exceeding the limit aborts the save/load of the whole style list.","triggerScenarios":"setInlineStylesData receives an InlineStyle whose trimmed Name is longer than 64 runes; loadInlineStyles reads a config file containing an over-long style name (e.g. pasted descriptive text as the style name).","commonSituations":"Pasting a long CSS description or sentence into the style-name field; scripts generating names from style content; CJK names — although counted per rune, long Chinese names can still pass 64 runes.","solutions":["Shorten the style name to 64 runes or fewer (trim on the client before saving).","Truncate programmatically: cut the name to utf8.RuneCountInString(name) <= 64, on a rune boundary.","Move the descriptive text into a comment or separate field and keep the name a short label."],"exampleFix":"// before\nstyle.Name = strings.Repeat(\"very long descriptive name \", 10) // > 64 runes\n// after\nname := []rune(rawName)\nif len(name) > 64 {\n    name = name[:64]\n}\nstyle.Name = string(name)","handlingStrategy":"validation","validationCode":"for (const s of styles) { if ([...s.Name.trim()].length > 64) throw new Error(`style ${s.ID} name exceeds 64 characters`); }","typeGuard":null,"tryCatchPattern":"try { await saveStyles(styles) } catch (e) { if (/name exceeds/.test(String(e))) { styles = styles.map(s => ({...s, Name: [...s.Name].slice(0, 64).join('')})); /* retry */ } }","preventionTips":["Cap name inputs at 64 characters in the UI (maxLength=64)","Truncate on rune boundaries, not bytes, for CJK text","Treat the limit as runes, matching the server's utf8.RuneCountInString"],"tags":["validation","length-limit","inline-styles","unicode"],"backgroundTag":"value-out-of-range","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"}