{"record":{"id":"719c4b9448ad5edd","repo":"siyuan-note/siyuan","slug":"skill-resource-read-failed-s-s","errorCode":null,"errorMessage":"skill resource read failed: %s/%s","messagePattern":"skill resource read failed: (.+?)/(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/util/skill.go","lineNumber":385,"sourceCode":"\t\treturn \"\", fmt.Errorf(\"skill resource escapes skill directory: %s\", resource)\n\t}\n\n\tinfo, err := os.Stat(realTarget)\n\tif err != nil || !info.Mode().IsRegular() {\n\t\treturn \"\", fmt.Errorf(\"skill resource is not a regular file: %s/%s\", skillName, resource)\n\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()","sourceCodeStart":367,"sourceCodeEnd":403,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/util/skill.go#L367-L403","documentation":"readSkillResource reads the file contents with io.ReadAll over a limited reader. If the read itself fails (I/O error while streaming the file), it returns 'skill resource read failed' with the skill and resource names.","triggerScenarios":"io.ReadAll fails mid-read: disk I/O error, file truncated/modified concurrently, network drive disconnected, or the underlying file handle becoming invalid during the read.","commonSituations":"Failing or full disk; resource stored on a network mount that dropped; the skill directory synced by an external tool (cloud drive) that rewrites files during the read.","solutions":["Retry the LoadSkill call — transient I/O errors often clear","Check disk health and free space on the workspace volume (dmesg / S.M.A.R.T.)","Exclude the skills directory from cloud-sync tools that rewrite files in place, or pause sync while reading","Copy the skill to local disk if it resides on an unreliable mount"],"exampleFix":"// before\ncontent, err := LoadSkill(\"my-skill\", \"reference.md\") // fails on flaky NFS\n// after\ncontent, err := LoadSkill(\"my-skill\", \"reference.md\")\nif err != nil && strings.Contains(err.Error(), \"read failed\") {\n    // fall back to a cached copy of the resource\n    content = cachedResource[\"my-skill/reference.md\"]\n}","handlingStrategy":"try-catch","validationCode":"// ensure local disk and free space\nif fi, err := os.Stat(p); err == nil && onNetworkMount(p) { /* prefer local copy */ }","typeGuard":null,"tryCatchPattern":"content, err := LoadSkill(skill, resource)\nif err != nil && strings.Contains(err.Error(), \"skill resource read failed\") {\n    content = fallbackFromCache(skill, resource) // degrade gracefully\n}","preventionTips":["Keep skill directories on local, healthy storage","Exclude skills from in-place cloud-sync rewriting","Monitor disk health and free space"],"tags":["skill","filesystem","io"],"backgroundTag":"file-read-failed","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"}