{"record":{"id":"33b4bc2159823826","repo":"flipped-aurora/gin-vue-admin","slug":"w-33b4bc","errorCode":null,"errorMessage":"前端目录无效: %w","messagePattern":"前端目录无效: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/service/system/auto_code_task.go","lineNumber":62,"sourceCode":"\tAfterHash     string\n\tBeforeContent []byte\n\tStagedPath    string\n}\n\ntype autoCodeFilePublisher func(file *autoCodeTaskFile) (published bool, err error)\n\nfunc newAutoCodeTaskLayout(root, server, web string) (autoCodeTaskLayout, error) {\n\troot, err := filepath.Abs(root)\n\tif err != nil {\n\t\treturn autoCodeTaskLayout{}, fmt.Errorf(\"解析自动代码根目录失败: %w\", err)\n\t}\n\tserverRoot, err := pathWithin(root, server)\n\tif err != nil {\n\t\treturn autoCodeTaskLayout{}, fmt.Errorf(\"服务端目录无效: %w\", err)\n\t}\n\twebRoot, err := pathWithin(root, web)\n\tif err != nil {\n\t\treturn autoCodeTaskLayout{}, fmt.Errorf(\"前端目录无效: %w\", err)\n\t}\n\treturn autoCodeTaskLayout{\n\t\troot:       filepath.Clean(root),\n\t\tserverRoot: serverRoot,\n\t\twebRoot:    webRoot,\n\t}, nil\n}\n\nfunc prepareAutoCodeFileTask(layout autoCodeTaskLayout, files map[string][]byte) (_ *autoCodeFileTask, err error) {\n\tstagingDir, err := os.MkdirTemp(layout.root, autoCodeStagingPrefix)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"创建自动代码 staging 目录失败: %w\", err)\n\t}\n\ttask := &autoCodeFileTask{\n\t\tlayout:     layout,\n\t\tstagingDir: stagingDir,\n\t\tfiles:      make([]autoCodeTaskFile, 0, len(files)),\n\t}","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/flipped-aurora/gin-vue-admin/blob/3136500ef380842b0eb6c4daa87c3f8a47fcf9e0/server/service/system/auto_code_task.go#L44-L80","documentation":"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.","triggerScenarios":"Create (or testAutoCodeTaskLayout) receives a web path that resolves outside root: absolute path, '..' traversal, or symlinks escaping the root directory.","commonSituations":"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.","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."],"exampleFix":"// before (config)\nautoCode:\n  web: /var/www/other-frontend\n// after\nautoCode:\n  web: web","handlingStrategy":"validation","validationCode":"webAbs, _ := filepath.Abs(web)\nrootAbs, _ := filepath.Abs(root)\nif !strings.HasPrefix(webAbs+string(os.PathSeparator), rootAbs+string(os.PathSeparator)) {\n    return fmt.Errorf(\"web path %s escapes root %s\", webAbs, rootAbs)\n}","typeGuard":null,"tryCatchPattern":"layout, err := newAutoCodeTaskLayout(root, server, web)\nif err != nil {\n    return fmt.Errorf(\"invalid autoCode config: %w\", err)\n}","preventionTips":["Configure web as a relative subdirectory of root.","Re-check config after repo restructuring.","Resolve symlinks before validation."],"tags":["filesystem","path-traversal","auto-code","config"],"backgroundTag":"path-escape-rejected","analyzedSha":"3136500ef380842b0eb6c4daa87c3f8a47fcf9e0","analyzedAt":"2026-08-31T13:50:02.721Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}