e2e: parse codex rollout session id as JSON, not regex · Entire
e2e: parse codex rollout session id as JSON, not regex
1386ab4→main·
toothbrush·2w ago·1 file·+27 added/-5 removed
TestCodexResumeRestoredSessionWithSanitizedCompactedHistory failed every run on main: readCodexSessionID anchored a regex on the session_meta line's field order, which Codex changed in 0.142.x, so it matched nothing ("session_meta id not found in rollout"). The CLI parses the same file fine via JSON. Decode the rollout line-by-line and read payload.id the same way, so the test survives future Codex field reordering.
Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com
Sessions
524d2d090bd7View transcript
Changes
1
e2e/tests
Mcodex_resume_test.go+27/-5
2 unmodified lines
3
4
5
6
7
8
9
10
10
11
12
13
63 unmodified lines
77
78
79
80
81
82
83
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
2 unmodified lines
package tests
import (
"bytes"
"context"
"encoding/json"
"os"
"path/filepath"
"regexp"
"testing"
"time"
63 unmodified lines
data, err := os.ReadFile(rolloutPath)
require.NoError(t, err)
re := regexp.MustCompile(`(?m)^\{"timestamp":".*","type":"session_meta","payload":\{"id":"([^"]+)"`)
m := re.FindSubmatch(data)
require.Len(t, m, 2, "session_meta id not found in rollout")
return string(m[1])
// Codex rollout files are JSONL; the session id lives in the payload of the
// first "session_meta" line. Parse line-by-line rather than anchoring a
// regex on field order — Codex reorders JSON keys between versions (the old
// regex silently stopped matching on Codex 0.142.x). This mirrors the CLI's
// own parser in cmd/entire/cli/agent/codex/transcript.go.
for _, raw := range bytes.Split(data, []byte("\n")) {
if len(bytes.TrimSpace(raw)) == 0 {
continue
}
var line struct {
Type string `json:"type"`
Payload json.RawMessage `json:"payload"`
}
if err := json.Unmarshal(raw, &line); err != nil || line.Type != "session_meta" {
continue
}
var payload struct {
ID string `json:"id"`
}
require.NoError(t, json.Unmarshal(line.Payload, &payload))
require.NotEmpty(t, payload.ID, "session_meta payload missing id")
return payload.ID
}
t.Fatalf("session_meta line not found in rollout %s", rolloutPath)
return ""
}
func appendCompactedEncryptedHistory(t *testing.T, rolloutPath string) {