Skip to content

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

@kuishou68

Description

@kuishou68

Description

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

Code

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.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions