t8y2/dbx · error
query session not found: %s
Error message
query session not found: %s
What it means
Paged query results are stored in per-session querySessions keyed by an id returned when the query was started. fetchQueryPage returns this error when asked to fetch the next page for an id that has no entry, typically because the query finished (all pages consumed), the session was closed, or the id is wrong.
Source
Thrown at agents/drivers/neo4j-go/query.go:97
HasMore: false,
}, nil
}
id := s.nextQuerySessionID()
s.querySessions[id] = &querySession{
session: session, result: result, ctx: ctx, cancel: cancel,
columns: columns, columnTypes: columnTypes, remaining: remaining,
}
return queryPageResult{
Columns: columns, ColumnTypes: columnTypes, Rows: rows,
ExecutionTimeMS: time.Since(started).Milliseconds(), SessionID: &id, HasMore: true,
}, nil
}
func (s *server) fetchQueryPage(id string, pageSize int) (queryPageResult, error) {
started := time.Now()
query := s.querySessions[id]
if query == nil {
return queryPageResult{}, fmt.Errorf("query session not found: %s", id)
}
if pageSize <= 0 {
pageSize = defaultPageSize
}
if pageSize > query.remaining {
pageSize = query.remaining
}
rows, _, _, hasMore, err := readResultPage(query.ctx, query.result, pageSize)
if err != nil {
s.closeQuerySession(id)
return queryPageResult{}, err
}
query.remaining -= len(rows)
truncated := hasMore && query.remaining <= 0
if !hasMore || query.remaining <= 0 {
s.closeQuerySession(id)
return queryPageResult{
Columns: query.columns, ColumnTypes: query.columnTypes, Rows: rows,View on GitHub (pinned to c0390bff16)
Solutions
- Stop paginating once the result reports no remaining rows and do not call fetch again with that id
- Re-run the query to obtain a fresh query session id if the old one is gone
- Verify the id passed to fetch is the one returned by the query call for that same session
- Check the agent process has not restarted (in-memory registry is lost)
Example fix
// before
for { page, err := fetch(id); if err != nil { return err } } // fetches past the end
// after
for remaining > 0 {
page, err := fetch(id)
if err != nil { return err }
remaining -= len(page.Rows)
} Defensive patterns
Strategy: try-catch
Validate before calling
// stop paginating when the previous page says no rows remain
if queryState.remaining == 0 {
return io.EOF // do not call fetch again with this id
} Try / catch
page, err := call("fetch", map[string]any{"id": id, "page_size": n})
if err != nil && strings.Contains(err.Error(), "query session not found") {
// id consumed or lost: restart the query rather than retrying the id
id, err = startQuery(origSQL)
if err != nil { return err }
page, err = call("fetch", map[string]any{"id": id, "page_size": n})
}
return err Prevention
- Treat query session ids as single-use: drop after the final page
- Never persist query ids across agent restarts
- Track remaining rows client-side and stop at zero
- Map each id to exactly one logical query to avoid cross-session mixups
When it happens
Trigger: Calling fetchQueryPage with an id that was never returned by query start, an id from a closed query session, or an id whose entry was deleted after the final page was consumed (remaining == 0).
Common situations: Client paginating past the last page and reusing a freed id; caching query ids across an agent restart; mixing ids between two sessions; a client bug double-fetching the same completed query.
Related errors
- agent session not found: %s
- View source not found: " + name
- MongoDB collection '<sourceName>' was not found
- Unknown query session: " + sessionId
- Object source not found
AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05).
Data as JSON: /api/errors/c1d3c7cdb04a4577.
Report an issue: GitHub.