{"record":{"id":"c924b6b7c86b2ce5","repo":"chenhg5/cc-connect","slug":"work-dir-does-not-exist-s","errorCode":null,"errorMessage":"work_dir does not exist: %s","messagePattern":"work_dir does not exist: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/setup.go","lineNumber":521,"sourceCode":"\t\tmgmtError(w, http.StatusInternalServerError, \"save config: \"+err.Error())\n\t\treturn\n\t}\n\tmgmtJSON(w, http.StatusCreated, map[string]any{\n\t\t\"message\":          fmt.Sprintf(\"platform %q added to project %q\", req.Type, projectName),\n\t\t\"restart_required\": true,\n\t})\n}\n\nfunc validateProjectWorkDir(workDir string) (string, error) {\n\ttrimmed := strings.TrimSpace(workDir)\n\tif trimmed == \"\" {\n\t\treturn \"\", nil\n\t}\n\n\tinfo, err := os.Stat(trimmed)\n\tif err != nil {\n\t\tif os.IsNotExist(err) {\n\t\t\treturn \"\", fmt.Errorf(\"work_dir does not exist: %s\", trimmed)\n\t\t}\n\t\treturn \"\", fmt.Errorf(\"work_dir is not accessible: %s: %w\", trimmed, err)\n\t}\n\tif !info.IsDir() {\n\t\treturn \"\", fmt.Errorf(\"work_dir is not a directory: %s\", trimmed)\n\t}\n\treturn trimmed, nil\n}\n","sourceCodeStart":503,"sourceCodeEnd":530,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/core/setup.go#L503-L530","documentation":"validateProjectWorkDir rejects a configured project work_dir when os.Stat reports the path does not exist. Configuration is validated eagerly so project agents never start in a missing directory; the trimmed path is echoed back in the error.","triggerScenarios":"Saving a project (handleProjectDetail, handleSetupFeishuSave, handleSetupWeixinSave, handleProjectAddPlatform) with a work_dir pointing to a path that was deleted, never created, or mistyped.","commonSituations":"Typos in config.toml or the web setup form; directory removed after initial configuration; relative paths resolved against an unexpected working directory; Docker/volume mounts not present on the host.","solutions":["Create the directory: mkdir -p <path>, or correct the path in the project config","Use an absolute path to avoid ambiguity about the process working directory","If the directory lives in a container/volume, verify the mount exists on the host running cc-connect"],"exampleFix":"// before\nwork_dir = \"~/projects/app\"\n// after\nwork_dir = \"/home/alice/projects/app\"  # must exist: mkdir -p /home/alice/projects/app","handlingStrategy":"validation","validationCode":"wd := strings.TrimSpace(cfg.WorkDir)\nif wd == \"\" { return errors.New(\"work_dir is required\") }\nabs, err := filepath.Abs(wd)\nif err != nil { return err }\nif info, err := os.Stat(abs); err != nil {\n    return fmt.Errorf(\"work_dir missing: %s: %w\", abs, err)\n} else if !info.IsDir() {\n    return fmt.Errorf(\"work_dir is not a directory: %s\", abs)\n}","typeGuard":null,"tryCatchPattern":"dir, err := validateProjectWorkDir(cfg.WorkDir)\nif err != nil {\n    if strings.HasPrefix(err.Error(), \"work_dir does not exist\") {\n        if mkErr := os.MkdirAll(strings.TrimSpace(cfg.WorkDir), 0o755); mkErr == nil {\n            dir, err = validateProjectWorkDir(cfg.WorkDir)\n        }\n    }\n    if err != nil { slog.Error(\"invalid work_dir\", \"err\", err) }\n}","preventionTips":["Use absolute paths for work_dir in config.toml and setup forms","Pre-flight check the directory exists before saving project config","If the directory may live on a mount, verify the mount is up before starting cc-connect"],"tags":["config","filesystem","directory"],"backgroundTag":"file-not-found","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}