{"record":{"id":"770b28aab9b1f59c","repo":"siyuan-note/siyuan","slug":"skill-resource-is-not-a-regular-file-s-s","errorCode":null,"errorMessage":"skill resource is not a regular file: %s/%s","messagePattern":"skill resource is not a regular file: (.+?)/(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/util/skill.go","lineNumber":372,"sourceCode":"\nfunc readSkillResource(skillDir, skillName, resource string) (string, error) {\n\trealRoot, err := filepath.EvalSymlinks(skillDir)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"skill not found: %s\", skillName)\n\t}\n\n\ttarget := filepath.Join(realRoot, filepath.FromSlash(resource))\n\trealTarget, err := filepath.EvalSymlinks(target)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"skill resource not found: %s/%s\", skillName, resource)\n\t}\n\tif realTarget != realRoot && !gulu.File.IsSubPath(realRoot, realTarget) {\n\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) {","sourceCodeStart":354,"sourceCodeEnd":390,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/util/skill.go#L354-L390","documentation":"readSkillResource stats the resolved target and requires it to be a regular file. Directories, devices, sockets, and other special files are rejected, returning this error with the skill name and resource path.","triggerScenarios":"LoadSkill is called with a resource path that resolves to a directory (e.g. requesting the skill root or a subfolder) or another non-regular filesystem object.","commonSituations":"Passing a directory path instead of a file path (e.g. \"docs\" instead of \"docs/index.md\"); the resource being replaced by a FIFO or device node; skill folders assembled manually with unexpected entries.","solutions":["Append the filename to the resource path so it points at a regular file","Verify with os.Stat that the target is a regular file before calling","Recreate the skill resource as a regular file if it was replaced by a special file"],"exampleFix":"// before\nLoadSkill(\"my-skill\", \"reference\") // directory\n// after\nLoadSkill(\"my-skill\", \"reference/guide.md\") // regular file","handlingStrategy":"validation","validationCode":"fi, err := os.Stat(filepath.Join(util.SkillsDir(), skill, filepath.FromSlash(resource)))\nif err != nil || !fi.Mode().IsRegular() { /* not a readable file — abort */ }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always point resources at files, not directories","Verify with os.Stat + Mode().IsRegular() before loading","Do not place FIFOs/devices inside skill directories"],"tags":["skill","filesystem","not-a-regular-file"],"backgroundTag":"file-not-found","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"}