cloudwego / cloudwego/eino

bug: wrong variable in error message in compose/values_merge.go

Open Beginner friendly
#974 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
13k
Forks
1.1k
Avg merge
4h 6m
Merged PRs (30d)
41

Description

## Description

In `compose/values_merge.go`, the `mergeValues` function contains a wrong variable in the error message when checking stream reader types.

## Code

```go
ss := make([]streamReader, len(vs)-1)
for i := 0; i < len(ss); i++ {
sri, ok_ := vs[i+1].(streamReader)
if !ok_ {
return nil, fmt.Errorf("(mergeStream) unexpected type. "+
"expect: %v, got: %v", t0, reflect.TypeOf(vs[i])) // BUG: should be vs[i+1]
}
```

## Bug

When the type assertion `vs[i+1].(streamReader)` fails, the error message shows `reflect.TypeOf(vs[i])` (the **previous** element) instead of `reflect.TypeOf(vs[i+1])` (the element that actually failed the assertion).

This causes the error message to report the wrong type, making debugging significantly harder because the user sees a type that successfully passed the assertion rather than the one that failed.

## Fix

Change `reflect.TypeOf(vs[i])` to `reflect.TypeOf(vs[i+1])` on the error line.

```go
return nil, fmt.Errorf("(mergeStream) unexpected type. "+
"expect: %v, got: %v", t0, reflect.TypeOf(vs[i+1])) // FIXED
```

Contributor guide

Open the contributing guide

Research direction

Open compose/values_merge.go and read the mergeValues function, focusing on the streamReader type assertion and its error path. Change the reported type to the element whose assertion failed, then verify that the error message identifies that element rather than the previous one.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
82/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.