{"record":{"id":"569b065258849b03","repo":"chenhg5/cc-connect","slug":"session-file-not-found-for-s-569b06","errorCode":null,"errorMessage":"session file not found for %s","messagePattern":"session file not found for (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agent/codex/list.go","lineNumber":251,"sourceCode":"\n\tvar found string\n\t_ = filepath.Walk(sessionsDir, func(path string, info os.FileInfo, err error) error {\n\t\tif err != nil || info.IsDir() || found != \"\" {\n\t\t\treturn nil\n\t\t}\n\t\tif strings.Contains(filepath.Base(path), sessionID) {\n\t\t\tfound = path\n\t\t}\n\t\treturn nil\n\t})\n\treturn found\n}\n\n// getSessionHistory reads the JSONL transcript and returns user/assistant messages.\nfunc getSessionHistory(sessionID, codexHome string, limit int) ([]core.HistoryEntry, error) {\n\tpath := findSessionFile(sessionID, codexHome)\n\tif path == \"\" {\n\t\treturn nil, fmt.Errorf(\"session file not found for %s\", sessionID)\n\t}\n\n\tf, err := os.Open(path)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer f.Close()\n\n\tvar entries []core.HistoryEntry\n\n\tscanner := bufio.NewScanner(f)\n\tscanner.Buffer(make([]byte, 256*1024), 256*1024)\n\n\tfor scanner.Scan() {\n\t\tline := scanner.Text()\n\t\tif line == \"\" {\n\t\t\tcontinue\n\t\t}","sourceCodeStart":233,"sourceCodeEnd":269,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/agent/codex/list.go#L233-L269","documentation":"getSessionHistory resolves a session ID to its rollout JSONL file with findSessionFile before parsing the transcript. If no file is found it returns this error instead of attempting os.Open on an empty path. It indicates the requested session's history does not exist on disk.","triggerScenarios":"GetSessionHistory(sessionID, ...) when findSessionFile returns \"\" — the session ID has no matching rollout file under codexHome.","commonSituations":"Requesting /history for a stale/deleted session; codexHome mismatch (CODEX_HOME changed); typo'd or foreign session ID; codex pruned old sessions automatically.","solutions":["List sessions first and pass an ID returned by ListSessions.","Verify codexHome points at the CODEX_HOME used when the session ran.","Handle the not-found case gracefully in the UI (show 'no history') instead of surfacing an error."],"exampleFix":"// before\nhistory, err := agent.GetSessionHistory(ctx, id, 50)\nif err != nil { return err }\n// after\nhistory, err := agent.GetSessionHistory(ctx, id, 50)\nif err != nil {\n    if strings.Contains(err.Error(), \"session file not found\") {\n        return []core.HistoryEntry{}, nil\n    }\n    return err\n}","handlingStrategy":"validation","validationCode":"sessions, _ := agent.ListSessions(ctx)\nvalid := map[string]bool{}\nfor _, s := range sessions { valid[s.ID] = true }\nif !valid[sessionID] {\n    return nil, fmt.Errorf(\"unknown session %q; use ListSessions\", sessionID)\n}\nhistory, err := agent.GetSessionHistory(ctx, sessionID, limit)","typeGuard":null,"tryCatchPattern":"history, err := agent.GetSessionHistory(ctx, id, limit)\nif err != nil {\n    if strings.Contains(err.Error(), \"session file not found\") {\n        return []core.HistoryEntry{}, nil // show empty history\n    }\n    return err\n}","preventionTips":["Validate session IDs against ListSessions before fetching history.","Handle pruned/old sessions by returning empty history in the UI layer.","Keep CODEX_HOME consistent between session creation and later queries.","Surface a friendly 'session expired' message instead of a raw error."],"tags":["session","history","file-not-found"],"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"}