t8y2/dbx · error
checked one driver
Error message
checked one driver
What it means
tar_zstd_driver_package_info first validates that a tar.zst offline driver package contains exactly one driver, then calls registry.drivers.iter().next().expect("checked one driver") to extract it. The expect relies on the length check immediately above; it can only panic if the validation and extraction are separated or the length check is bypassed, which would be a code-invariant break.
Source
Thrown at crates/dbx-core/src/agent_service.rs:2588
InstalledDriver {
version: info.version.clone(),
installed_at: chrono::Utc::now().to_rfc3339(),
jre: info.jre.clone(),
},
);
})?;
}
am.stop_daemon_by_key(&info.db_type).await;
result.drivers_installed.push(info.db_type);
Ok(result)
}
fn tar_zstd_driver_package_info(package_path: &Path) -> Result<TarZstdDriverPackageInfo, String> {
let registry = read_registry_from_tar_zstd(package_path)?;
if registry.drivers.len() != 1 {
return Err("A tar.zst driver package must contain exactly one driver".to_string());
}
let (db_type, driver) = registry.drivers.iter().next().expect("checked one driver");
validate_offline_driver_key(db_type)?;
let current_platform = AgentManager::current_platform();
let (native_platform, native_artifact) = if let Some(artifact) = driver.native.get(current_platform) {
(Some(current_platform.to_string()), Some(artifact))
} else if driver.native.len() == 1 {
let (platform, artifact) = driver.native.iter().next().expect("checked one native platform");
(Some(platform.clone()), Some(artifact))
} else {
(None, None)
};
let jar_artifact = usable_driver_jar(driver);
let (kind, artifact) = match (native_artifact, jar_artifact) {
(Some(_), Some(_)) => {
return Err("A tar.zst driver package must contain exactly one driver artifact".to_string());
}
(Some(artifact), None) => (DriverArtifactKind::Native, artifact),
(None, Some(artifact)) => (DriverArtifactKind::Jar, artifact),
(None, None) if !driver.native.is_empty() => {View on GitHub (pinned to c0390bff16)
Solutions
- Keep the len()!=1 guard immediately before extraction; never call iter().next() without it.
- If you need a multi-driver tar.zst, use the registry-import path that supports multiple drivers instead of this single-driver helper.
- For robustness, use a match on registry.drivers.len() returning a Result rather than expect.
- Rebuild/repackage the offline driver so the archive contains exactly one driver.
Example fix
// before
let (db_type, driver) = registry.drivers.iter().next().expect("checked one driver");
// after
let Some((db_type, driver)) = registry.drivers.into_iter().next() else {
return Err("A tar.zst driver package must contain exactly one driver".to_string());
}; Defensive patterns
Strategy: validation
Validate before calling
// before importing a tar.zst driver package, check the registry layout
let registry = read_registry_from_tar_zstd(path)?;
if registry.drivers.len() != 1 {
return Err(format!(
"package must contain exactly one driver, found {}",
registry.drivers.len()
));
} Type guard
fn single_driver(registry: &DriverRegistry) -> Option<(&str, &OfflineDriver)> {
if registry.drivers.len() == 1 { registry.drivers.iter().next() } else { None }
} Try / catch
let Some((db_type, driver)) = registry.drivers.iter().next() else {
return Err("A tar.zst driver package must contain exactly one driver".to_string());
}; Prevention
- Build offline driver packages with exactly one driver entry.
- Validate package layout right after packaging in CI.
- Keep length guards adjacent to iterator extraction.
- Use a single_entry helper returning Result instead of expect.
When it happens
Trigger: Programmatically impossible when the preceding `if registry.drivers.len() != 1 { return Err(...) }` guard is intact; it panics only if the guard is removed/reordered during refactoring or iter().next() is called on a mutated map. The real user-facing failure from this area is the Err "A tar.zst driver package must contain exactly one driver".
Common situations: Users building offline driver packages with zero or multiple drivers hit the Err message; developers refactoring the parsing function may turn the silent guard into a panic; packages built by older tooling versions with different layouts.
Related errors
- checked one native platform
- a batch cancellation token is always available
- driver token registered
- a cancellation token is always available
- root count checked above
AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05).
Data as JSON: /api/errors/a2704bfa1c344483.
Report an issue: GitHub.