{"record":{"id":"b7486053fd3a3844","repo":"Tencent/WeKnora","slug":"failed-to-load-script-w","errorCode":null,"errorMessage":"failed to load script: %w","messagePattern":"failed to load script: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/agent/skills/manager.go","lineNumber":449,"sourceCode":"//     as WorkDir.\nfunc buildSkillExecuteConfig(\n\tsource SkillSource,\n\tskillName, scriptPath, basePath string,\n\targs []string,\n\tstdin string,\n\tenv map[string]string,\n\tsessionID string,\n) (*sandbox.ExecuteConfig, error) {\n\tif workspace, ok := sandbox.RunnableWorkspaceScript(scriptPath); ok {\n\t\treturn workspaceSkillExecuteConfig(source, skillName, workspace, basePath, args, stdin, env, sessionID)\n\t}\n\n\timage, installed := source.(imageSkillSource)\n\tif !installed {\n\t\t// Load the script file to verify it exists and is a script\n\t\tfile, err := source.LoadSkillFile(skillName, scriptPath)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to load script: %w\", err)\n\t\t}\n\t\tif !file.IsScript {\n\t\t\treturn nil, fmt.Errorf(\"file is not an executable script: %s\", scriptPath)\n\t\t}\n\t\treturn &sandbox.ExecuteConfig{\n\t\t\tScript:    file.Path,\n\t\t\tArgs:      args,\n\t\t\tWorkDir:   basePath,\n\t\t\tStdin:     stdin,\n\t\t\tEnv:       env,\n\t\t\tSessionID: sessionID,\n\t\t}, nil\n\t}\n\n\t// The archive is deliberately not consulted: the image is what executes,\n\t// and a skill whose archive failed to store is still installed and\n\t// runnable. That leaves the extension as the only check available here,\n\t// which is also the one the executor's interpreter choice depends on.","sourceCodeStart":431,"sourceCodeEnd":467,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/agent/skills/manager.go#L431-L467","documentation":"buildSkillExecuteConfig wraps any error from source.LoadSkillFile when the skill is NOT installed in the sandbox image (preloaded/host skill). The underlying cause — missing file, unreadable path, archive error — is preserved via %w; this wrapper adds context that the script could not be loaded from the skill's host files.","triggerScenarios":"Manager.ExecuteScript with a skill-relative scriptPath on a preloaded (non-image) skill where LoadSkillFile fails: the relative path does not exist in the skill directory, the path escapes the skill dir, or the skill's files are unreadable.","commonSituations":"Typo in the script path (e.g. script/run.py vs scripts/run.py); the SKILL.md references a script that was not shipped in the skill archive; filesystem permission problems on the host skill directory.","solutions":["Fix the underlying wrapped error shown after 'failed to load script:' — usually a wrong or missing script path relative to the skill root","Check the skill directory contents (GetSkillInfo / ListSkillFiles) to confirm the script exists at the given relative path","Re-upload/reinstall the skill if its archive is missing files","Verify read permissions on the skill's host directory"],"exampleFix":"// before\nmgr.ExecuteScript(ctx, \"pdf\", \"script/run.py\", nil, \"\")   // wrong dir\n// after\nmgr.ExecuteScript(ctx, \"pdf\", \"scripts/run.py\", nil, \"\")  // matches skill layout","handlingStrategy":"validation","validationCode":"files, err := mgr.ListSkillFiles(skillName)\nif err != nil { return err }\nif !slices.Contains(files, scriptPath) {\n    return fmt.Errorf(\"%s not present in skill %s\", scriptPath, skillName)\n}","typeGuard":"func scriptExistsInSkill(m *skills.Manager, skill, path string) bool {\n    files, err := m.ListSkillFiles(skill)\n    if err != nil { return false }\n    return slices.Contains(files, path)\n}","tryCatchPattern":"cfg, err := mgr.ExecuteScript(ctx, skill, path, args, stdin)\nif err != nil {\n    var wrapped interface{ Unwrap() error }\n    if strings.HasPrefix(err.Error(), \"failed to load script:\") {\n        log.Printf(\"script %s missing in skill %s: %v\", path, skill, err)\n    }\n    return err\n}","preventionTips":["Validate script paths against ListSkillFiles before executing","Keep SKILL.md script references in sync with the shipped archive contents","Use skill-relative paths exactly as listed by the skill metadata","Re-upload skills after editing their file layout"],"tags":["go","filesystem","path","skill-script"],"backgroundTag":"file-not-found","analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}