{"record":{"id":"86b27ef0937c6978","repo":"chenhg5/cc-connect","slug":"iflowsession-resolve-session-dir-w","errorCode":null,"errorMessage":"iflowSession: resolve session dir: %w","messagePattern":"iflowSession: resolve session dir: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agent/iflow/session.go","lineNumber":158,"sourceCode":"\t\tmode:           s.mode,\n\t\tpendingTimeout: s.pendingToolTimeout(),\n\t\tprocessDone:    make(chan struct{}),\n\t\tpendingToolIDs: make(map[string]struct{}),\n\t\tpendingTools:   make(map[string]iflowToolUse),\n\t\tseenToolIDs:    make(map[string]struct{}),\n\t\tdoneToolIDs:    make(map[string]struct{}),\n\t}\n\n\tdefer func() {\n\t\tif !s.turnActive.Load() {\n\t\t\tturnCancel()\n\t\t}\n\t}()\n\n\tsessionDir, err := iflowSessionDir(s.workDir)\n\tif err != nil {\n\t\ts.turnActive.Store(false)\n\t\treturn fmt.Errorf(\"iflowSession: resolve session dir: %w\", err)\n\t}\n\tturn.sessionDir = sessionDir\n\n\targs := append([]string{}, s.extraArgs...)\n\tif s.model != \"\" {\n\t\targs = append(args, \"-m\", s.model)\n\t}\n\n\tswitch s.mode {\n\tcase \"yolo\":\n\t\targs = append(args, \"--yolo\")\n\tcase \"plan\":\n\t\targs = append(args, \"--plan\")\n\tcase \"auto-edit\":\n\t\targs = append(args, \"--autoEdit\")\n\tdefault:\n\t\targs = append(args, \"--default\")\n\t}","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/agent/iflow/session.go#L140-L176","documentation":"Send wraps a failure from iflowSessionDir, which locates the directory where the iflow CLI stores its session data for this working directory. If the directory cannot be resolved (missing/unreadable paths, unexpected layout), Send aborts the turn and releases the busy flag.","triggerScenarios":"Calling Send() when iflowSessionDir(s.workDir) fails — typically because the iflow CLI has never run in that workDir so no session dir exists yet, the path is unreadable due to permissions, or a symlink/home-dir lookup failed.","commonSituations":"workDir misconfigured in config.toml (nonexistent or wrong path); iflow CLI never initialized in the container/home; running under a different user with no access to ~/.iflow; HOME unset in daemonized environment.","solutions":["Verify workDir exists and is writable by the cc-connect process","Run the iflow CLI once manually in workDir to initialize its session directory","Check HOME/env of the daemon (systemd/launchd often have a different HOME); set it explicitly","Fix filesystem permissions on the iflow session directory path"],"exampleFix":"// before\nworkDir = \"/home/app/projects\" // path never used by iflow\n// after\nif err := os.MkdirAll(workDir, 0o755); err != nil { log.Fatal(err) }\n// ensure the iflow CLI was run once in workDir before starting sessions","handlingStrategy":"validation","validationCode":"if st, err := os.Stat(workDir); err != nil || !st.IsDir() {\n    return fmt.Errorf(\"workDir invalid: %s\", workDir)\n}","typeGuard":null,"tryCatchPattern":"if err := session.Send(ctx, msg, nil); err != nil {\n    var wrapped error\n    if errors.As(err, &wrapped) && strings.Contains(err.Error(), \"resolve session dir\") {\n        log.Printf(\"fix iflow session dir for workDir; cause: %v\", wrapped)\n    }\n}","preventionTips":["Validate workDir exists and is writable at agent construction, not first Send","Initialize the iflow CLI once in workDir during provisioning","Pin HOME/PATH explicitly in daemon unit files"],"tags":["go","filesystem","iflow","session"],"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"}