siyuan-note/siyuan · error

skill resource read failed

Error message

skill resource read failed: %s/%s

What it means

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.

Solutions

  1. Retry the LoadSkill call — transient I/O errors often clear
  2. Check disk health and free space on the workspace volume (dmesg / S.M.A.R.T.)
  3. Exclude the skills directory from cloud-sync tools that rewrite files in place, or pause sync while reading
  4. Copy the skill to local disk if it resides on an unreliable mount

Example fix

// before
content, err := LoadSkill("my-skill", "reference.md") // fails on flaky NFS
// after
content, err := LoadSkill("my-skill", "reference.md")
if err != nil && strings.Contains(err.Error(), "read failed") {
    // fall back to a cached copy of the resource
    content = cachedResource["my-skill/reference.md"]
}
Defensive patterns

Strategy: try-catch

Validate before calling

// ensure local disk and free space
if fi, err := os.Stat(p); err == nil && onNetworkMount(p) { /* prefer local copy */ }

Try / catch

content, err := LoadSkill(skill, resource)
if err != nil && strings.Contains(err.Error(), "skill resource read failed") {
    content = fallbackFromCache(skill, resource) // degrade gracefully
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.

Related errors


AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19). Data as JSON: /api/errors/719c4b9448ad5edd. Report an issue: GitHub.

Appendix: source

Thrown at kernel/util/skill.go:385

		return "", fmt.Errorf("skill resource escapes skill directory: %s", resource)
	}

	info, err := os.Stat(realTarget)
	if err != nil || !info.Mode().IsRegular() {
		return "", fmt.Errorf("skill resource is not a regular file: %s/%s", skillName, resource)
	}
	if info.Size() > maxSkillResourceBytes {
		return "", fmt.Errorf("skill resource exceeds the %d byte limit: %s/%s", maxSkillResourceBytes, skillName, resource)
	}

	file, err := os.Open(realTarget)
	if err != nil {
		return "", fmt.Errorf("skill resource not found: %s/%s", skillName, resource)
	}
	defer file.Close()
	data, err := io.ReadAll(io.LimitReader(file, maxSkillResourceBytes+1))
	if err != nil {
		return "", fmt.Errorf("skill resource read failed: %s/%s", skillName, resource)
	}
	if len(data) > maxSkillResourceBytes {
		return "", fmt.Errorf("skill resource exceeds the %d byte limit: %s/%s", maxSkillResourceBytes, skillName, resource)
	}
	if !utf8.Valid(data) {
		return "", fmt.Errorf("skill resource is not valid UTF-8: %s/%s", skillName, resource)
	}
	return string(data), nil
}

func validateSkillName(name string) error {
	if name == "" || name == "." || name == ".." {
		return fmt.Errorf("invalid skill name: %s", name)
	}
	if strings.ContainsAny(name, `/\`) {
		return fmt.Errorf("invalid skill name: %s", name)
	}
	dir := SkillsDir()

View on GitHub (pinned to 9f775e8a12)