Skip to content

Regression in 1.3: Decoder conceals underlying error when ReaderBufferSize is > 0 #421

@dop251

Description

@dop251

After upgrading to 1.3 I've noticed that the decoder does not wrap the original error in the following test case as it used to:

type testFaultyReader struct {

}

func (t testFaultyReader) Read(p []byte) (n int, err error) {
	return 0, net.ErrClosed
}

func TestUgorjiErrorPropagation(t *testing.T) {
	var r testFaultyReader
	h := &codec.JsonHandle{}
	h.ReaderBufferSize = 4096 // Commenting this out makes the test pass
	dec := codec.NewDecoder(r, h)
	var v any
	err := dec.Decode(&v)
	if !errors.Is(err, net.ErrClosed) {
		t.Fatal(err)
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions