flipped-aurora/gin-vue-admin · error
前端目录无效: %w
Error message
前端目录无效: %w
What it means
Thrown by newAutoCodeTaskLayout when pathWithin(root, web) rejects the configured web (frontend) subdirectory as outside the auto-code root. Same sandbox check as the server path, applied to the frontend tree where generated Vue files are published.
Source
Thrown at server/service/system/auto_code_task.go:62
AfterHash string
BeforeContent []byte
StagedPath string
}
type autoCodeFilePublisher func(file *autoCodeTaskFile) (published bool, err error)
func newAutoCodeTaskLayout(root, server, web string) (autoCodeTaskLayout, error) {
root, err := filepath.Abs(root)
if err != nil {
return autoCodeTaskLayout{}, fmt.Errorf("解析自动代码根目录失败: %w", err)
}
serverRoot, err := pathWithin(root, server)
if err != nil {
return autoCodeTaskLayout{}, fmt.Errorf("服务端目录无效: %w", err)
}
webRoot, err := pathWithin(root, web)
if err != nil {
return autoCodeTaskLayout{}, fmt.Errorf("前端目录无效: %w", err)
}
return autoCodeTaskLayout{
root: filepath.Clean(root),
serverRoot: serverRoot,
webRoot: webRoot,
}, nil
}
func prepareAutoCodeFileTask(layout autoCodeTaskLayout, files map[string][]byte) (_ *autoCodeFileTask, err error) {
stagingDir, err := os.MkdirTemp(layout.root, autoCodeStagingPrefix)
if err != nil {
return nil, fmt.Errorf("创建自动代码 staging 目录失败: %w", err)
}
task := &autoCodeFileTask{
layout: layout,
stagingDir: stagingDir,
files: make([]autoCodeTaskFile, 0, len(files)),
}View on GitHub (pinned to 3136500ef3)
Solutions
- Set web to a relative path inside the auto-code root (e.g. 'web').
- Remove traversal segments/symlinks; confirm with filepath.EvalSymlinks.
- Correct the autoCode web entry in the server config.
Example fix
// before (config) autoCode: web: /var/www/other-frontend // after autoCode: web: web
Defensive patterns
Strategy: validation
Validate before calling
webAbs, _ := filepath.Abs(web)
rootAbs, _ := filepath.Abs(root)
if !strings.HasPrefix(webAbs+string(os.PathSeparator), rootAbs+string(os.PathSeparator)) {
return fmt.Errorf("web path %s escapes root %s", webAbs, rootAbs)
} Try / catch
layout, err := newAutoCodeTaskLayout(root, server, web)
if err != nil {
return fmt.Errorf("invalid autoCode config: %w", err)
} Prevention
- Configure web as a relative subdirectory of root.
- Re-check config after repo restructuring.
- Resolve symlinks before validation.
When it happens
Trigger: Create (or testAutoCodeTaskLayout) receives a web path that resolves outside root: absolute path, '..' traversal, or symlinks escaping the root directory.
Common situations: Config web path changed to an absolute location or contains '..'; repository restructured so the configured web folder no longer sits under root; symlinked web directory.
Related errors
AI-assisted analysis of flipped-aurora/gin-vue-admin@3136500ef3 (2026-08-31).
Data as JSON: /api/errors/33b4bc2159823826.
Report an issue: GitHub.