Hmbown/CodeWhale · error · io::Error

evidence metadata exceeds limit

Error message

evidence metadata exceeds limit

What it means

read_evidence_metadata_file reads the evidence metadata sidecar capped at MAX_MANIFEST_BYTES (64 KiB) via Read::take. If the file exceeds that cap the read is truncated and the function returns InvalidData with "evidence metadata exceeds limit" instead of parsing a partial document. This guards the session log and memory against oversized or corrupted manifests.

Solutions

  1. Delete or regenerate the oversized sidecar (remove the evidence metadata file next to the artifact) so it is rewritten on next publish.
  2. Inspect the file (`ls -l`, `wc -c`) to confirm it is bloated/corrupt before deleting.
  3. If legitimate metadata now exceeds 64 KiB, raise MAX_MANIFEST_BYTES or split the artifact into multiple metadata files.
  4. Fix any writer that appends instead of atomically replacing the sidecar.

Example fix

// before
ls -l ~/.local/state/codewhale/artifacts/<sid>/evidence/meta.json  # 210000 bytes
// after
rm ~/.local/state/codewhale/artifacts/<sid>/evidence/meta.json  # regenerated on next publish_evidence_metadata
Defensive patterns

Strategy: validation

Validate before calling

// shell check before read
[ "$(stat -c%s "$SIDECAR")" -le 65536 ] || echo "sidecar too large; regenerate it"

Try / catch

// rust
match read_evidence_metadata(&handle) {
    Err(e) if e.kind() == std::io::ErrorKind::InvalidData && e.to_string().contains("exceeds limit") => {
        eprintln!("metadata sidecar over 64 KiB; delete and regenerate");
    }
    other => other?,
}

Prevention

When it happens

Trigger: read_evidence_metadata -> read_evidence_metadata_file encountering a metadata sidecar larger than 64 KiB — typically a file corrupted by a past bug, appended garbage, or an artifact schema that grew past the limit.

Common situations: A previous version wrote unbounded metadata; concurrent writes produced a bloated/partial file; a hand-edited or externally modified sidecar; many large entries accumulated in one artifact.

Understand the failure class

Background: "File too large" / "file size exceeds limit" errors: why libraries cap file sizes and how to fix them — this error's family across 46 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/bbe41f3500d12388. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/src/tools/large_output_router.rs:327

pub fn read_evidence_metadata(session_id: &str, handle: &str) -> io::Result<EvidenceArtifact> {
    let relative = evidence_metadata_relative_path(handle);
    let file = crate::artifacts::open_session_relative(session_id, &relative, false)?;
    read_evidence_metadata_file(&file)
}

/// Bounded, no-follow read shared by publication/replay and authenticated HTTP
/// retrieval. The caller chooses the existing session-root authority.
pub(crate) fn read_evidence_metadata_file(
    file: &crate::fleet::files::WorkspaceFile,
) -> io::Result<EvidenceArtifact> {
    use std::io::Read;
    const MAX_MANIFEST_BYTES: u64 = 64 * 1024;
    let mut raw = Vec::new();
    file.open_file()?
        .take(MAX_MANIFEST_BYTES + 1)
        .read_to_end(&mut raw)?;
    if raw.len() as u64 > MAX_MANIFEST_BYTES {
        return Err(io::Error::new(
            io::ErrorKind::InvalidData,
            "evidence metadata exceeds limit",
        ));
    }
    serde_json::from_slice(&raw).map_err(|err| io::Error::new(io::ErrorKind::InvalidData, err))
}

#[must_use]
pub fn unix_millis_now() -> u64 {
    std::time::SystemTime::now()
        .duration_since(std::time::UNIX_EPOCH)
        .unwrap_or_default()
        .as_millis()
        .try_into()
        .unwrap_or(u64::MAX)
}

#[must_use]

View on GitHub (pinned to 73e0f67d83)