toeverything/AFFiNE · error · io::Error
InvalidInput
InvalidInput
Error message
invalid mobile file token
What it means
read_binary_file guard: the value passed as a blob reference does not carry the MOBILE_BLOB_FILE_PREFIX, so it is not a mobile file token at all; an InvalidInput io::Error is returned instead of attempting a filesystem read.
Source
Thrown at packages/frontend/mobile-native/src/cache/mod.rs:287
for entry in std::fs::read_dir(cache_dir)? {
let entry = entry?;
if entry.path().is_file() {
let _ = std::fs::remove_file(entry.path());
}
}
Ok(())
}
}
pub(crate) fn is_mobile_binary_file_token(value: &str) -> bool {
value.starts_with(MOBILE_BLOB_FILE_PREFIX)
}
impl MobileBlobCache {
pub(crate) fn read_binary_file(&self, universal_id: &str, value: &str) -> std::io::Result<Vec<u8>> {
let path = value
.strip_prefix(MOBILE_BLOB_FILE_PREFIX)
.ok_or_else(|| std::io::Error::new(std::io::ErrorKind::InvalidInput, "invalid mobile file token"))?;
let path = path.strip_prefix("file://").unwrap_or(path);
let canonical = std::fs::canonicalize(path)?;
let workspace_dir = {
self
.workspace_dirs
.read()
.expect("workspace cache lock poisoned")
.get(universal_id)
.cloned()
}
.ok_or_else(|| std::io::Error::new(std::io::ErrorKind::NotFound, "workspace cache directory not registered"))?;
let workspace_dir = std::fs::canonicalize(workspace_dir)?;
if !is_valid_mobile_cache_path(&canonical, &workspace_dir) {
return Err(std::io::Error::new(
std::io::ErrorKind::PermissionDenied,
"mobile file token points outside the workspace cache directory",View on GitHub (pinned to b4c8548c09)
Solutions
- Issue a fresh mobile file token from the cache layer.
- Do not forge or modify file tokens.
Defensive patterns
Strategy: validation
When it happens
Trigger: Raised in read_binary_file when the stored value does not start with the expected MOBILE_BLOB_FILE_PREFIX, so the token cannot be stripped to a path.
Common situations: A blob value that is not a mobile file token was passed to the file reader. Only values produced by the mobile blob cache should be read this way.
AI-assisted analysis of toeverything/AFFiNE@b4c8548c09 (2026-08-18).
Data as JSON: /api/errors/41977df5d54845d5.
Report an issue: GitHub.