xai-org/grok-build · error

{e}

Error message

{e}

What it means

The session_search extension handler runs walk_admitted_window, whose error type is converted into an anyhow error via anyhow::anyhow!(e) and reported verbatim as "{e}". Because the message is just the inner error's Display, the JSON surfaces whatever the walk/fetch layer reported — typically an underlying storage or fetch failure while paging the session search window.

Source

Thrown at crates/codegen/xai-grok-shell/src/extensions/session_search.rs:145

                            .into_iter()
                            .map(|hit| {
                                let kind = kind_index.kind(&hit.session_id);
                                (hit, kind)
                            })
                            .collect::<Vec<_>>()
                    })
                    .await
                    .map_err(io::Error::other)?;
                    Ok(ClassifiedPage {
                        hits,
                        has_more,
                        bootstrapping,
                    })
                }
            };
            let result = walk_admitted_window(fetch, offset, limit, headless)
                .await
                .map_err(|e| anyhow::anyhow!(e));

            super::to_ext_response(result)
        }
        _ => Err(acp::Error::method_not_found()),
    }
}

const MAX_SEARCH_RESULTS: usize = 100;
const MAX_FILTERED_OFFSET: usize = 1_000;
/// Hard cap on authoritative summary resolutions for one request.
const MAX_CLASSIFIED_HITS: usize = 1_200;
const WALK_BATCH: usize = 50;

fn validate_search_window(limit: usize, offset: usize) -> Result<(), acp::Error> {
    if limit == 0 || limit > MAX_SEARCH_RESULTS || offset > MAX_FILTERED_OFFSET {
        return Err(acp::Error::invalid_params().data(format!(
            "session search limit must be 1..={MAX_SEARCH_RESULTS} and offset <= {MAX_FILTERED_OFFSET}"
        )));

View on GitHub (pinned to bc7f02eddd)

Solutions

  1. Read the inner error text ({e}) to identify the actual storage/fetch failure and fix that root cause
  2. Retry with offset=0 and a small limit to rule out out-of-range pagination arguments
  3. Verify the sessions directory/storage is readable and not corrupted
Defensive patterns

Strategy: try-catch

Validate before calling

// sanity-check pagination args before the call
if limit == 0 || offset > max_known_offset {
    return Err("offset/limit out of admitted window".into());
}

Try / catch

match ext("x.ai/session-search", req).await {
    Ok(resp) => resp,
    Err(e) => {
        // message is the inner error verbatim; log it and fall back
        log::warn!("session search failed: {e}");
        SessionSearchResponse::default()
    }
}

Prevention

When it happens

Trigger: Calling the session_search extension method when the underlying session store/fetch callback fails during pagination (bad offset/limit, unreadable session index, IO error fetching a window).

Common situations: Corrupted or missing session storage; offset beyond the admitted window; permission issues reading the sessions directory; headless mode fetching from an unavailable source.


AI-assisted analysis of xai-org/grok-build@bc7f02eddd (2026-08-31). Data as JSON: /api/errors/be96c3f6d2aa6551. Report an issue: GitHub.