astrid-runtime/astrid · error
mount callback response is too large
Error message
mount callback response is too large
What it means
After the MAX_CALLBACK_FRAME_BYTES check, write_response converts the serialized length to u32 for the big-endian length prefix. If the length does not fit in u32 (practically: > 4 GiB, i.e. the frame-bytes check did not catch it), this second InvalidData error fires. It is a defensive guard ensuring the wire format's u32 length field is always representable.
Solutions
- Restore/keep MAX_CALLBACK_FRAME_BYTES below u32::MAX so the length always fits
- Fix the earlier guard rather than the conversion: the frame-bytes check should reject the response first
- If huge responses are required, redesign the protocol to chunk responses instead of enlarging the length prefix
Example fix
// before const MAX_CALLBACK_FRAME_BYTES: usize = usize::MAX; // after const MAX_CALLBACK_FRAME_BYTES: usize = u32::MAX as usize;
Defensive patterns
Strategy: try-catch
Validate before calling
fn fits_u32_length_prefix(bytes_len: usize) -> bool {
bytes_len <= u32::MAX as usize
}
assert!(fits_u32_length_prefix(ser_len), "length must fit u32 frame prefix"); Try / catch
match result {
Err(e) if e.to_string() == "mount callback response is too large" => {
eprintln!("protocol bug: response exceeded u32 length prefix; enforce frame cap");
}
other => other?,
} Prevention
- Never raise MAX_CALLBACK_FRAME_BYTES above u32::MAX
- Keep the frame-size guard ahead of the u32 conversion in code review
- Treat this error as an internal invariant breach, not a client-fixable condition
When it happens
Trigger: bytes.len() > u32::MAX after passing the MAX_CALLBACK_FRAME_BYTES check — only reachable if MAX_CALLBACK_FRAME_BYTES is configured above 4 GiB or the check is bypassed by code changes.
Common situations: Someone raised MAX_CALLBACK_FRAME_BYTES to u64/usize max to 'remove limits'; a refactor removed the earlier size check so giant responses reach the u32 conversion.
Understand the failure class
Background: payload too large / request exceeds maximum size: why libraries cap bytes and how to fix oversize payloads — this error's family across 50 libraries.
Related errors
- mount callback response exceeds limit
- environment value for
- filesystem payload exceeds limit
- FSKit callback response exceeds the bounded frame size
- FSKit service control request exceeds limit
AI-assisted analysis of astrid-runtime/astrid@affd8760f4 (2026-09-09).
Data as JSON: /api/errors/55b28825309f0371.
Report an issue: GitHub.
Appendix: source
Thrown at crates/astrid-kernel/src/storage_mount.rs:687
#[cfg(any(unix, windows))]
async fn write_response(
stream: &mut LocalStream,
response: CallbackResponse,
) -> Result<(), io::Error> {
let bytes = match response {
CallbackResponse::V1(response) => serde_json::to_vec(&response),
CallbackResponse::V2(response) => serde_json::to_vec(&response),
}
.map_err(io::Error::other)?;
if bytes.len() > MAX_CALLBACK_FRAME_BYTES {
return Err(io::Error::new(
io::ErrorKind::InvalidData,
"mount callback response exceeds limit",
));
}
let length = u32::try_from(bytes.len()).map_err(|_| {
io::Error::new(
io::ErrorKind::InvalidData,
"mount callback response is too large",
)
})?;
stream.write_all(&length.to_be_bytes()).await?;
stream.write_all(&bytes).await?;
stream.flush().await
}
async fn dispatch_request(
kernel: &Kernel,
state: &StorageMountLeaseState,
callback: CallbackRequest,
) -> CallbackResponse {
let request = callback.request;
let request_id = request.request_id.clone();
let outcome = if !state.is_live() {
failure("stale-lease", "storage mount lease is expired or revoked")View on GitHub (pinned to affd8760f4)