xai-org/grok-build · error

not a file: {}

Error message

not a file: {}

What it means

Error "not a file: {}" thrown in xai-org/grok-build.

Source

Thrown at crates/codegen/xai-grok-shell/src/session/file_system.rs:174

pub async fn read_file(abs_path: &Path) -> Result<FsReadFileData> {
    let bytes = tokio::fs::read(abs_path).await?;
    Ok(build_file_entry(&bytes))
}

/// Binary-safe ranged read: returns the chunk `[offset, offset + min(length,
/// max_bytes, cap))` with the full file `size`. `lineCount` is omitted and
/// the MIME `type` is a coarse text/binary tag (mid-file chunks defeat
/// magic-byte sniffing).
pub(crate) async fn read_file_ranged(
    abs_path: &Path,
    offset: u64,
    length: u64,
    max_bytes: u64,
    encoding: FsReadEncoding,
) -> Result<FsReadFileData> {
    let md = tokio::fs::metadata(abs_path).await?;
    if md.is_dir() {
        anyhow::bail!("not a file: {}", abs_path.display());
    }
    // Best-effort snapshot: a concurrent truncate/grow between here and
    // read_range can make `size` inconsistent with the returned chunk.
    let size = md.len();
    let length = wfs::clamp_read_length(Some(length), max_bytes);
    let chunk = wfs::read_range(abs_path, offset, length).await?;
    let (payload, is_text) = wfs::encode_chunk(chunk, encoding);
    let (content, content_base64) = match payload {
        wfs::ChunkPayload::Text(t) => (t, None),
        wfs::ChunkPayload::Base64(b) => (String::new(), Some(b)),
    };
    Ok(FsReadFileData {
        content,
        content_base64,
        size,
        line_count: None,
        content_type: if is_text {
            "text/plain".to_string()

View on GitHub (pinned to bc7f02eddd)

When it happens

Trigger: Thrown at crates/codegen/xai-grok-shell/src/session/file_system.rs:174 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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