{"record":{"id":"ba9fc276c55daba9","repo":"chenhg5/cc-connect","slug":"opencodesession-create-image-dir-w","errorCode":null,"errorMessage":"opencodeSession: create image dir: %w","messagePattern":"opencodeSession: create image dir: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agent/opencode/session.go","lineNumber":125,"sourceCode":"\n\tif err := cmd.Start(); err != nil {\n\t\treturn fmt.Errorf(\"opencodeSession: start: %w\", err)\n\t}\n\n\ts.wg.Add(1)\n\tgo s.readLoop(cmd, stdout, &stderrBuf)\n\n\treturn nil\n}\n\nfunc (s *opencodeSession) stageImages(prompt string, images []core.ImageAttachment) (string, []string, error) {\n\tif len(images) == 0 {\n\t\treturn prompt, nil, nil\n\t}\n\n\timgDir := filepath.Join(s.workDir, \".cc-connect\", \"images\")\n\tif err := os.MkdirAll(imgDir, 0o755); err != nil {\n\t\treturn \"\", nil, fmt.Errorf(\"opencodeSession: create image dir: %w\", err)\n\t}\n\n\timagePaths := make([]string, 0, len(images))\n\tfor i, img := range images {\n\t\text := opencodeImageExt(img.MimeType)\n\t\tfname := fmt.Sprintf(\"img_%d_%d%s\", time.Now().UnixMilli(), i, ext)\n\t\tfpath := filepath.Join(imgDir, fname)\n\t\tif err := os.WriteFile(fpath, img.Data, 0o644); err != nil {\n\t\t\treturn \"\", nil, fmt.Errorf(\"opencodeSession: save image: %w\", err)\n\t\t}\n\t\timagePaths = append(imagePaths, fpath)\n\t}\n\n\tif prompt == \"\" {\n\t\tprompt = \"Please analyze the attached image(s).\"\n\t}\n\n\treturn prompt, imagePaths, nil","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/agent/opencode/session.go#L107-L143","documentation":"Wraps a failed os.MkdirAll of <workDir>/.cc-connect/images in opencodeSession.stageImages. It fires when the workDir (or the staging subdir) is not writable, so image attachments cannot be staged for the outgoing prompt.","triggerScenarios":"Thrown at agent/opencode/session.go:125 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix write permissions on the project workDir","Remove any file occupying the .cc-connect name","Retry the image message after repair"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}