chenhg5/cc-connect · error

codexSession: save image: %w

Error message

codexSession: save image: %w

What it means

Wraps a failed os.WriteFile while persisting one staged image attachment under .cc-connect/images for the codex turn. It fires on per-file IO problems: disk full, quota exceeded, or an invalid generated filename/path on exotic filesystems.

Source

Thrown at agent/codex/session.go:194

}

func (cs *codexSession) stageImages(prompt string, images []core.ImageAttachment) (string, []string, error) {
	if len(images) == 0 {
		return prompt, nil, nil
	}

	imgDir := filepath.Join(cs.workDir, ".cc-connect", "images")
	if err := os.MkdirAll(imgDir, 0o755); err != nil {
		return "", nil, fmt.Errorf("codexSession: create image dir: %w", err)
	}

	imagePaths := make([]string, 0, len(images))
	for i, img := range images {
		ext := codexImageExt(img.MimeType)
		fname := fmt.Sprintf("img_%d_%d%s", time.Now().UnixMilli(), i, ext)
		fpath := filepath.Join(imgDir, fname)
		if err := os.WriteFile(fpath, img.Data, 0o644); err != nil {
			return "", nil, fmt.Errorf("codexSession: save image: %w", err)
		}
		imagePaths = append(imagePaths, fpath)
	}

	if strings.TrimSpace(prompt) == "" {
		prompt = "Please analyze the attached image(s)."
	}

	return prompt, imagePaths, nil
}

func (cs *codexSession) buildExecArgs(prompt string, imagePaths []string) []string {
	tid := cs.CurrentSessionID()
	isResume := tid != ""

	var args []string
	if isResume {
		// For resume: codex exec resume ... <thread_id> [--image ...] --json --cd <dir> <prompt>

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Free disk space on the volume hosting the workDir
  2. Check filesystem errors (quota, read-only remount)
  3. Retry the send; staging is cleaned on failure
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at agent/codex/session.go:194 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06). Data as JSON: /api/errors/6424dd259234345e. Report an issue: GitHub.