{"record":{"id":"979bb47519a96a24","repo":"astrid-runtime/astrid","slug":"invalid-base64-filesystem-payload-error","errorCode":null,"errorMessage":"invalid base64 filesystem payload: {error}","messagePattern":"invalid base64 filesystem payload: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-kernel/src/storage_mount.rs","lineNumber":640,"sourceCode":"        },\n        StorageFilesystemOperationV2::Read {\n            path,\n            offset,\n            length,\n        } => StorageFilesystemOperationV1::Read {\n            path,\n            offset,\n            length,\n        },\n        StorageFilesystemOperationV2::Write {\n            path,\n            offset,\n            data_base64,\n        } => {\n            let data = base64::engine::general_purpose::STANDARD\n                .decode(data_base64.as_bytes())\n                .map_err(|error| {\n                    io::Error::new(\n                        io::ErrorKind::InvalidData,\n                        format!(\"invalid base64 filesystem payload: {error}\"),\n                    )\n                })?;\n            let data_length = u64::try_from(data.len()).unwrap_or(u64::MAX);\n            if data_length > STORAGE_FILESYSTEM_MAX_IO_BYTES {\n                return Err(io::Error::new(\n                    io::ErrorKind::InvalidData,\n                    \"filesystem payload exceeds limit\",\n                ));\n            }\n            StorageFilesystemOperationV1::Write { path, offset, data }\n        },\n        StorageFilesystemOperationV2::SetLength { path, length } => {\n            StorageFilesystemOperationV1::SetLength { path, length }\n        },\n        StorageFilesystemOperationV2::Create { path, kind } => {\n            StorageFilesystemOperationV1::Create { path, kind }","sourceCodeStart":622,"sourceCodeEnd":658,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-kernel/src/storage_mount.rs#L622-L658","documentation":"decode_operation_v2 unwraps the base64-encoded data section of a Write operation using the standard base64 alphabet. If the payload is not valid base64 (bad characters, wrong padding, whitespace), the decode fails and the error is wrapped in an InvalidData io::Error with the underlying base64 message.","triggerScenarios":"A Write operation sent over the mount callback socket carries a data_base64 string that the STANDARD base64 engine cannot decode — e.g. URL-safe '-_' characters, missing '=' padding, embedded newlines, or corrupted/truncated frames.","commonSituations":"A client base64-encodes with a URL-safe engine while the kernel expects standard; manually crafting JSON requests with unencoded binary; frames truncated mid-payload by a length-prefix bug.","solutions":["Encode payloads with the standard base64 engine (base64::engine::general_purpose::STANDARD) on the client side","Fix padding: ensure the base64 string length is a multiple of 4 with correct '=' padding","Strip whitespace/newlines from the payload before sending","Log the failing base64 message from the error text to identify the exact invalid character or padding problem"],"exampleFix":"// before\nlet encoded = base64::engine::general_purpose::URL_SAFE.encode(&data);\n// after\nlet encoded = base64::engine::general_purpose::STANDARD.encode(&data);","handlingStrategy":"validation","validationCode":"use base64::engine::general_purpose::STANDARD;\nfn is_valid_base64(s: &str) -> bool {\n    STANDARD.decode(s.as_bytes()).is_ok()\n}\nassert!(is_valid_base64(&payload.data_base64), \"payload must be standard-alphabet base64\");","typeGuard":"fn validate_base64_field(op: &Operation) -> Option<&str> {\n    match op {\n        Operation::Write { data_base64, .. } if\n            base64::engine::general_purpose::STANDARD.decode(data_base64.as_bytes()).is_ok()\n            => Some(data_base64),\n        _ => None,\n    }\n}","tryCatchPattern":"match result {\n    Err(e) if e.kind() == io::ErrorKind::InvalidData\n        && e.to_string().starts_with(\"invalid base64 filesystem payload\") => {\n        eprintln!(\"client sent malformed base64: re-encode with STANDARD engine\");\n    }\n    other => other?,\n}","preventionTips":["Always encode with base64::engine::general_purpose::STANDARD, not URL_SAFE or NO_PAD","Never hand-write base64 payloads in test fixtures — generate them with the encoder","Sanitize/trim whitespace from payloads before framing them"],"tags":["base64","encoding","ipc"],"backgroundTag":"invalid-argument-format","analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}