{"record":{"id":"41a567f8c6fe4c50","repo":"Tencent/WeKnora","slug":"failed-to-read-file-w","errorCode":null,"errorMessage":"failed to read file: %w","messagePattern":"failed to read file: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/agent/skills/loader.go","lineNumber":234,"sourceCode":"\tfullPath := filepath.Join(skill.BasePath, cleanPath)\n\n\t// Verify the file is within the skill directory\n\tabsSkillPath, err := filepath.Abs(skill.BasePath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tabsFilePath, err := filepath.Abs(fullPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif !strings.HasPrefix(absFilePath, absSkillPath) {\n\t\treturn nil, fmt.Errorf(\"file path outside skill directory: %s\", relativePath)\n\t}\n\n\t// Read the file\n\tcontent, err := os.ReadFile(fullPath)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to read file: %w\", err)\n\t}\n\n\treturn &SkillFile{\n\t\tName:     relativePath,\n\t\tPath:     absFilePath, // Use absolute path for sandbox execution\n\t\tContent:  string(content),\n\t\tIsScript: IsScript(relativePath),\n\t}, nil\n}\n\n// ListSkillFiles lists all files in a skill directory\nfunc (l *Loader) ListSkillFiles(skillName string) ([]string, error) {\n\tskill, ok := l.discoveredSkills[skillName]\n\tif !ok {\n\t\tvar err error\n\t\tskill, err = l.LoadSkillInstructions(skillName)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"skill not found: %s\", skillName)","sourceCodeStart":216,"sourceCodeEnd":252,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/agent/skills/loader.go#L216-L252","documentation":"I/O wrapper in LoadSkillFile: os.ReadFile failed on the already-validated fullPath inside the skill directory. The path passed traversal checks, so this is a genuine filesystem problem — missing file, permissions, or TOCTOU removal — not a security rejection.","triggerScenarios":"Thrown at internal/agent/skills/loader.go:234 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Confirm the file exists at the resolved path inside the skill directory","Fix read permissions on the file and its parent directories","Handle TOCTOU: re-list skill files if the directory changes during access"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}