SeleniumHQ/selenium · error · anyhow::Error
Payload is not a pbzx stream
Error message
Payload is not a pbzx stream
What it means
Raised by decode_pbzx() (files.rs:253) when the first 4 bytes of a .pkg Payload are not the ASCII magic 'pbzx'. Apple's modern .pkg Payload files are pbzx-wrapped cpio archives; a missing magic means the file is either an older format, corrupt, or not a Payload at all. decode_pbzx is called during macOS .pkg extraction.
Source
Thrown at rust/src/files.rs:253
move_dir(source, target, &options)?;
Ok(())
}
const PBZX_MAGIC: [u8; 4] = *b"pbzx";
const XZ_MAGIC: [u8; 6] = [0xfd, 0x37, 0x7a, 0x58, 0x5a, 0x00];
/// Decode a `pbzx` stream into the raw cpio archive it wraps.
///
/// `pbzx` is Apple's block-based container used for newer `.pkg` Payloads. It
/// consists of a `pbzx` magic, an 8-byte flags field, then a sequence of chunks
/// each prefixed by its big-endian decompressed and compressed sizes. A chunk is
/// xz-compressed unless its bytes are stored verbatim.
fn decode_pbzx(data: &[u8]) -> Result<Vec<u8>, Error> {
let mut cursor = Cursor::new(data);
let mut magic = [0u8; 4];
cursor.read_exact(&mut magic)?;
if magic != PBZX_MAGIC {
return Err(anyhow!("Payload is not a pbzx stream"));
}
// The 8-byte flags field is not needed to walk the chunks.
cursor.read_exact(&mut [0u8; 8])?;
let mut output = Vec::new();
let mut sizes = [0u8; 8];
loop {
match cursor.read_exact(&mut sizes) {
Ok(()) => {}
Err(err) if err.kind() == io::ErrorKind::UnexpectedEof => break,
Err(err) => return Err(err.into()),
}
// Decompressed size is recorded but not required to read the chunk.
cursor.read_exact(&mut sizes)?;
let compressed_size = u64::from_be_bytes(sizes) as usize;
let mut chunk = vec![0u8; compressed_size];
cursor.read_exact(&mut chunk)?;
View on GitHub (pinned to aa36b38e69)
Solutions
- Verify the .pkg is a modern Apple installer (use `xar -tf <pkg>` to list contents).
- Re-download the driver .pkg to rule out truncation.
- If the Payload is raw cpio, extend decode_pbzx to fall back to direct cpio handling.
- Run the extraction on genuine macOS where pkgutil handles all formats.
Defensive patterns
Strategy: validation
Validate before calling
# Bash: verify the .pkg Payload is a pbzx stream before decode PAYLOAD=$(xar -tf "$PKG" | grep -i Payload | head -1) xar -xf "$PKG" "$PAYLOAD" 2>/dev/null if [ "$(head -c4 "$PAYLOAD" 2>/dev/null)" != "pbzx" ]; then echo "Payload is not pbzx; may be legacy cpio or corrupt"; exit 1 fi
Try / catch
match decode_pbzx(&data) {
Ok(cpio) => cpio,
Err(e) if e.to_string().contains("not a pbzx stream") => {
eprintln!("Payload magic mismatch; re-download .pkg or handle legacy cpio");
return Err(e);
}
Err(e) => return Err(e),
} Prevention
- Verify .pkg integrity with `xar -tf` before extraction.
- Re-download truncated .pkg files.
- Run pkg extraction on genuine macOS where pkgutil handles all formats.
When it happens
Trigger: uncompress_pkg reads the Payload file and passes its bytes to decode_pbzx. cursor.read_exact(&mut magic) succeeds but magic != PBZX_MAGIC ('pbzx'). Typical when the .pkg uses a legacy uncompressed cpio Payload, the file is truncated, or a non-Payload was read.
Common situations: An older .pkg whose Payload is raw cpio (no pbzx wrapper); a corrupted/truncated download; the wrong file inside the .pkg was selected as Payload; a third-party packaging tool emits a different Payload format.
Related errors
- {} files are only supported in macOS
- Unsafe entry (path traversal): {:?}
- Format for file {} cannot be inferred
- Wrong browser/driver version
- Downloaded file cannot be uncompressed ({} extension)
AI-assisted analysis of SeleniumHQ/selenium@aa36b38e69 (2026-08-14).
Data as JSON: /api/errors/e8433f15445a3465.
Report an issue: GitHub.