Skip to content

SendMessageStream causes panic when iterator callback returns false #310

Closed
@vito

Description

@vito

The iterator returned by SendMessageStream doesn't respect a false return value from the callback function, leading to a panic if the callback breaks the loop.

yield(chunk, nil)

Environment details

  • Programming language: Go
  • OS: Linux
  • Language runtime version: 1.24.3
  • Package version: v1.4.0

Steps to reproduce

for res, err := range chat.SendMessageStream(ctx, parts...) {
  break
}
panic: runtime error: range function continued iteration after function for loop body returned false

goroutine 2932889 [running]:
github.com/dagger/dagger/core.(*GenaiClient).SendQuery.(*GenaiClient).processStreamResponse-range1(0xc06dbc7808?, {0x37a0160?, 0xc0add48850?})
	/app/core/llm_google.go:138 +0xa71
google.golang.org/genai.(*Chat).SendMessageStream.func1-range1(0x0, {0x37a0160?, 0xc0add48850?})
	/go/pkg/mod/google.golang.org/[email protected]/chats.go:135 +0x1ab

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions