Skip to content

fix: use resolved router variable instead of config.Router in routerRetriever#955

Open
kuishou68 wants to merge 1 commit into
cloudwego:mainfrom
kuishou68:fix/issue-954-router-nil-pointer
Open

fix: use resolved router variable instead of config.Router in routerRetriever#955
kuishou68 wants to merge 1 commit into
cloudwego:mainfrom
kuishou68:fix/issue-954-router-nil-pointer

Conversation

@kuishou68
Copy link
Copy Markdown

Summary

Fixes a nil pointer dereference bug in flow/retriever/router/router.go.

Problem

In NewRetriever, a local router variable is correctly resolved to a default function when config.Router is nil. However, the struct literal then stores config.Router (still nil) instead of the local router variable. This means calling Retrieve() without a custom Router configured panics at runtime:

runtime error: invalid memory address or nil pointer dereference

Fix

Change the struct initialization to use the resolved router variable:

// Before (buggy)
return &routerRetriever{
    retrievers: config.Retrievers,
    router:     config.Router,  // nil when Router not provided
    fusionFunc: fusion,
}, nil

// After (fixed)
return &routerRetriever{
    retrievers: config.Retrievers,
    router:     router,  // always non-nil: either config.Router or the default
    fusionFunc: fusion,
}, nil

Closes #954

…etriever (Closes cloudwego#954)

Signed-off-by: Cocoon-Break <54054995+kuishou68@users.noreply.github.com>
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 13, 2026

CLA assistant check
All committers have signed the CLA.

@shentongmartin shentongmartin added C-bugfix Category: This is a PR that fixes a bug. D-flow Domain: this issue relates to eino's flow package labels Apr 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-bugfix Category: This is a PR that fixes a bug. D-flow Domain: this issue relates to eino's flow package

Development

Successfully merging this pull request may close these issues.

bug: nil pointer dereference in flow/retriever/router when Router config is not provided

3 participants