Description
WriteReplayFrame returns (0, error) on marshaling failure, but the calling WriteFrame function ignores the return value entirely. If frame serialization fails, the frame is silently missing from the output with no error propagated to the caller.
Evidence
File: pkg/codec/echoreplay.go:119-140
func WriteReplayFrame(w io.Writer, frame *ReplayFrame) (int, error) {
data, err := json.Marshal(frame)
if err != nil {
return 0, err // returns error...
}
// ...
}
func (w *Writer) WriteFrame(frame *ReplayFrame) error {
WriteReplayFrame(w.writer, frame) // ...but caller ignores it
// ...
}
Impact
Failed serialization = missing frame, no error reported. If a frame contains data that can't be marshaled to JSON (e.g., NaN float values, circular references), it's silently dropped. The caller believes the write succeeded. This produces tape files with gaps that are indistinguishable from legitimate data.
Suggested Fix
Check and propagate the error:
func (w *Writer) WriteFrame(frame *ReplayFrame) error {
if _, err := WriteReplayFrame(w.writer, frame); err != nil {
return fmt.Errorf("writing replay frame: %w", err)
}
// ...
}
🤖 Filed by Metis
Description
WriteReplayFramereturns(0, error)on marshaling failure, but the callingWriteFramefunction ignores the return value entirely. If frame serialization fails, the frame is silently missing from the output with no error propagated to the caller.Evidence
File:
pkg/codec/echoreplay.go:119-140Impact
Failed serialization = missing frame, no error reported. If a frame contains data that can't be marshaled to JSON (e.g., NaN float values, circular references), it's silently dropped. The caller believes the write succeeded. This produces tape files with gaps that are indistinguishable from legitimate data.
Suggested Fix
Check and propagate the error:
🤖 Filed by Metis