{"record":{"id":"19c8f5150a7fde7c","repo":"siyuan-note/siyuan","slug":"skill-resource-is-not-valid-utf-8-s-s","errorCode":null,"errorMessage":"skill resource is not valid UTF-8: %s/%s","messagePattern":"skill resource is not valid UTF-8: (.+?)/(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/util/skill.go","lineNumber":391,"sourceCode":"\t}\n\tif info.Size() > maxSkillResourceBytes {\n\t\treturn \"\", fmt.Errorf(\"skill resource exceeds the %d byte limit: %s/%s\", maxSkillResourceBytes, skillName, resource)\n\t}\n\n\tfile, err := os.Open(realTarget)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"skill resource not found: %s/%s\", skillName, resource)\n\t}\n\tdefer file.Close()\n\tdata, err := io.ReadAll(io.LimitReader(file, maxSkillResourceBytes+1))\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"skill resource read failed: %s/%s\", skillName, resource)\n\t}\n\tif len(data) > maxSkillResourceBytes {\n\t\treturn \"\", fmt.Errorf(\"skill resource exceeds the %d byte limit: %s/%s\", maxSkillResourceBytes, skillName, resource)\n\t}\n\tif !utf8.Valid(data) {\n\t\treturn \"\", fmt.Errorf(\"skill resource is not valid UTF-8: %s/%s\", skillName, resource)\n\t}\n\treturn string(data), nil\n}\n\nfunc validateSkillName(name string) error {\n\tif name == \"\" || name == \".\" || name == \"..\" {\n\t\treturn fmt.Errorf(\"invalid skill name: %s\", name)\n\t}\n\tif strings.ContainsAny(name, `/\\`) {\n\t\treturn fmt.Errorf(\"invalid skill name: %s\", name)\n\t}\n\tdir := SkillsDir()\n\tabs := filepath.Join(dir, name)\n\tif !gulu.File.IsSubPath(dir, abs) {\n\t\treturn fmt.Errorf(\"invalid skill name: %s\", name)\n\t}\n\treturn nil\n}","sourceCodeStart":373,"sourceCodeEnd":409,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/util/skill.go#L373-L409","documentation":"Thrown by readSkillResource when the bytes read from the skill resource file are not valid UTF-8. Skill resources are served as text (LoadSkill feeds them to the AI runtime), so binary or non-UTF-8-encoded files under the skill directory are rejected with skillName/resource identifying the offending file; replace it with UTF-8 content.","triggerScenarios":"LoadSkill is called on a resource file encoded in another charset (GBK, Shift-JIS, Latin-1, UTF-16) or containing binary data.","commonSituations":"Skill documents authored on Windows in a legacy codepage; files saved by an editor with wrong encoding; accidentally placed binary assets (images, zip) referenced as text resources.","solutions":["Convert the resource file to UTF-8 (iconv -f GBK -t UTF-8 file.md > file.utf8.md, or re-save with editor encoding set to UTF-8)","Remove binary assets from text resource paths and reference them appropriately outside the skill-resource API","Ensure editors/tools write UTF-8 without legacy encodings when editing skill files"],"exampleFix":"// before\niconv -f GBK -t UTF-8 old.md > converted.md   # keep original name\nmv converted.md reference.md\n// after\nLoadSkill(\"my-skill\", \"reference.md\") // now valid UTF-8","handlingStrategy":"validation","validationCode":"b, err := os.ReadFile(p)\nif err == nil && !utf8.Valid(b) { /* convert to UTF-8 before loading */ }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Author and save all skill files as UTF-8","Convert legacy-encoded files (GBK/Shift-JIS/Latin-1) before importing","Keep binary assets out of text resource paths","Verify encoding after editing with external tools"],"tags":["skill","encoding","utf-8"],"backgroundTag":"invalid-argument-format","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"}