Skip to content

fix(compose): correct off-by-one in mergeStream error message#1056

Open
Dennisadira wants to merge 1 commit into
cloudwego:mainfrom
Dennisadira:fix/mergestream-error-msg
Open

fix(compose): correct off-by-one in mergeStream error message#1056
Dennisadira wants to merge 1 commit into
cloudwego:mainfrom
Dennisadira:fix/mergestream-error-msg

Conversation

@Dennisadira
Copy link
Copy Markdown

Summary

Fixes #974.

In compose/values_merge.go, the loop asserts vs[i+1] as a streamReader but on failure logs reflect.TypeOf(vs[i]) — the element before the one that failed:

sri, ok_ := vs[i+1].(streamReader)
if !ok_ {
    return nil, fmt.Errorf("(mergeStream) unexpected type. "+
        "expect: %v, got: %v", t0, reflect.TypeOf(vs[i]))  // wrong index
}

Changed vs[i]vs[i+1] so the error message reports the type of the element that actually failed the assertion.

Test plan

  • go test ./compose/... passes

Assisted-by: Claude Sonnet 4.6 noreply@anthropic.com

The type assertion checks vs[i+1] but the error message logged
reflect.TypeOf(vs[i]) — the preceding element — instead of the one
that actually failed the assertion.

Closes cloudwego#974

Assisted-by: Claude Sonnet 4.6 <noreply@anthropic.com>
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 31, 2026

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants