{"record":{"id":"5ed935623feb49c2","repo":"siyuan-note/siyuan","slug":"text-files-must-be-at-most-8-mib","errorCode":null,"errorMessage":"text files must be at most 8 MiB","messagePattern":"text files must be at most 8 MiB","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"kernel/util/skill_manage.go","lineNumber":32,"sourceCode":"\t\"path\"\n\t\"path/filepath\"\n\t\"strings\"\n\t\"sync\"\n\t\"unicode\"\n\t\"unicode/utf8\"\n\n\t\"github.com/88250/lute/ast\"\n\t\"github.com/siyuan-note/filelock\"\n)\n\nconst maxManagedSkillSourceSize = 8 * 1024 * 1024\n\nvar skillManagementLock sync.Mutex\n\nvar (\n\tErrSkillBinary   = errors.New(\"binary files cannot be edited as text\")\n\tErrSkillEncoding = errors.New(\"only UTF-8 text files can be edited\")\n\tErrSkillTooLarge = errors.New(\"text files must be at most 8 MiB\")\n)\n\ntype SkillFileRequest struct {\n\tAction   string\n\tPath     string\n\tTarget   string\n\tContent  string\n\tRevision string\n}\n\ntype SkillFileEntry struct {\n\tPath     string\n\tIsDir    bool\n\tEditable bool\n}\n\ntype SkillFileData struct {\n\tEntries        []SkillFileEntry","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/util/skill_manage.go#L14-L50","documentation":"ErrSkillTooLarge indicates a skill file exceeds the 8 MiB (maxManagedSkillSourceSize) text-editing limit. It is checked both on size at read time (readManagedSkillSource) and on submitted content length (validateManagedSkillSource), keeping the editor from loading or persisting oversized text.","triggerScenarios":"Reading a skill file whose on-disk size is > 8 MiB, or writing/creating a skill file whose content string length exceeds 8 MiB via ManageSkillFiles.","commonSituations":"Dumping large logs or generated data dumps into a skill file; pasting a huge dataset into the editor; an accidentally bundled large text artifact.","solutions":["Reduce the file below 8 MiB — split it or remove bulk content","Move large data out of the skill directory and reference it by path instead of inlining","If it is truly a data artifact, treat it as a non-editable resource rather than text"],"exampleFix":"// before\ncontent := hugeGeneratedDump // > 8 MiB\nManageSkillFiles(SkillFileRequest{Action: \"write\", Path: \"my-skill/SKILL.md\", Content: content})\n\n// after\ndata := hugeGeneratedDump\nif len(data) <= 8*1024*1024 {\n    ManageSkillFiles(SkillFileRequest{Action: \"write\", Path: \"my-skill/SKILL.md\", Content: data})\n}\n","handlingStrategy":"validation","validationCode":"const MAX = 8 * 1024 * 1024;\nif (new TextEncoder().encode(content).length > MAX) {\n  throw new Error('content exceeds 8 MiB skill file limit');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await api.manageSkillFiles({action: 'write', path, content});\n} catch (e) {\n  if (e.message.includes('at most 8 MiB')) {\n    // split or externalize the content\n  }\n}","preventionTips":["Check file size before reading/writing large skill files","Keep logs and data dumps out of skill directories","Split very large content into multiple files"],"tags":["file-size","limit","skill-editor","go"],"backgroundTag":"file-size-limit-exceeded","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"}