{"record":{"id":"2f20de3fae9a1a20","repo":"xai-org/grok-build","slug":"byte-budget-exceeded-new-total-max-total-bytes","errorCode":null,"errorMessage":"byte budget exceeded: {new_total}/{MAX_TOTAL_BYTES} bytes in {ARTIFACT_DIR}","messagePattern":"byte budget exceeded: (.+?)/(.+?) bytes in (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codegen/xai-grok-tools/src/implementations/grok_build/web_fetch/artifact.rs","lineNumber":56,"sourceCode":"fn save_locked(dir: &Path, data: &[u8], extension: &str) -> anyhow::Result<PathBuf> {\n    let mut allocation = std::fs::OpenOptions::new()\n        .read(true)\n        .write(true)\n        .create(true)\n        .truncate(false)\n        .open(dir.join(ALLOCATION_FILE))\n        .context(\"open allocation file\")?;\n    allocation\n        .lock_exclusive()\n        .context(\"lock allocation file\")?;\n\n    let (max_existing, total_bytes) = scan_artifacts(dir)?;\n    let number = reserve_number(&mut allocation, max_existing)?;\n    let new_total = total_bytes\n        .checked_add(u64::try_from(data.len()).context(\"artifact size exceeds u64\")?)\n        .context(\"artifact byte count overflow\")?;\n    if new_total > MAX_TOTAL_BYTES {\n        anyhow::bail!(\n            \"byte budget exceeded: {new_total}/{MAX_TOTAL_BYTES} bytes in {ARTIFACT_DIR}\"\n        );\n    }\n\n    let path = dir.join(format!(\"{number}.{extension}\"));\n    let mut tmp = tempfile::NamedTempFile::new_in(dir).context(\"create temp file\")?;\n    tmp.write_all(data).context(\"write temp file\")?;\n    tmp.as_file().sync_all().context(\"fsync temp file\")?;\n    tmp.persist_noclobber(&path)\n        .with_context(|| format!(\"persist to {}\", path.display()))?;\n    Ok(path)\n}\n\nfn reserve_number(file: &mut std::fs::File, max_existing: u32) -> anyhow::Result<u32> {\n    let stored = read_reserved_number(file)?.unwrap_or(max_existing);\n    let next = stored\n        .max(max_existing)\n        .checked_add(1)","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/xai-org/grok-build/blob/bc7f02eddd3d84085849dc19ed216f11c23b0571/crates/codegen/xai-grok-tools/src/implementations/grok_build/web_fetch/artifact.rs#L38-L74","documentation":"Error \"byte budget exceeded: {new_total}/{MAX_TOTAL_BYTES} bytes in {ARTIFACT_DIR}\" thrown in xai-org/grok-build.","triggerScenarios":"Thrown at crates/codegen/xai-grok-tools/src/implementations/grok_build/web_fetch/artifact.rs:56 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"bc7f02eddd3d84085849dc19ed216f11c23b0571","analyzedAt":"2026-08-31T04:59:42.031Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}