BigPizzaV3/CodexPlusPlus · error
Backup source database is not an allowed local storage path
Error message
Backup source database is not an allowed local storage path
What it means
After confirming the backup's source_db exists, backup_source_db canonicalizes it and bails unless it matches one of the allowed local storage database paths (allowed_db_paths, canonicalized). This is a path-safety whitelist: restore can only write into databases the adapter was explicitly configured to manage, not arbitrary SQLite files.
Solutions
- Construct the adapter with the actual DB location included in allowed_db_paths (compare canonicalized paths, not raw strings).
- Rewrite backup.source_db to the local equivalent path under the current codex_home before restoring.
- Check symlinks: ensure fs::canonicalize(source_db) equals one of the allowed paths; adjust symlinks or configuration.
- Re-create the backup on the current machine so source_db records a local allowed path.
Example fix
// before
let adapter = SQLiteStorageAdapter::new(); // default allowlist missing custom db location
// after
let adapter = SQLiteStorageAdapter::new()
.with_allowed_db_paths(vec![fs::canonicalize(&my_db_path)?]); // include the real (canonical) path Defensive patterns
Strategy: validation
Validate before calling
let canonical = fs::canonicalize(Path::new(backup["source_db"].as_str().unwrap()))?;
let allowed: bool = allowed_db_paths.iter()
.filter_map(|p| fs::canonicalize(p).ok())
.any(|p| p == canonical);
if !allowed { anyhow::bail!("source_db {:?} not in allowlist; configure with_allowed_db_paths", canonical); } Type guard
fn in_allowlist(path: &Path, allowed: &[PathBuf]) -> bool {
fs::canonicalize(path).ok()
.map(|c| allowed.iter().filter_map(|p| fs::canonicalize(p).ok()).any(|a| a == c))
.unwrap_or(false)
} Try / catch
match storage.restore_backups(&backup) {
Ok(()) => {}
Err(e) if e.to_string().contains("not an allowed local storage path") => {
eprintln!("{e}; reconfigure allowed_db_paths or re-anchor source_db");
}
Err(e) => return Err(e),
} Prevention
- Configure allowed_db_paths with canonicalized paths so symlinked homes compare correctly
- Rewrite backup source_db to local paths when importing backups from other machines
- Only construct backups through the library so source_db always records an allowed location
- Compare canonical paths, never raw strings, when validating DB locations
When it happens
Trigger: Calling restore_backups where backup.source_db resolves to a real file that is not in the adapter's allowed_db_paths — foreign absolute path, symlink resolving elsewhere, or adapter configured with a different (narrower) allowlist.
Common situations: Backups taken on another machine/user account with different absolute paths; CODEX_HOME moved or symlinked so canonicalize() differs from the configured path; adapter constructed without the needed path in allowed_db_paths (see LauncherDataService candidate_db_paths).
Understand the failure class
Background: Permission denied / not authorized / 403 Forbidden: access-control rejections when the caller lacks the required role, grant, or ownership — this error's family across 18 libraries.
Related errors
- Backup source database not found
- 无效的市场主题下载文件名
- invalid Dream Skin destination name
- Invalid runtime key
- restore conflict: agent_job_items row already assigned
AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19).
Data as JSON: /api/errors/441794687b127613.
Report an issue: GitHub.
Appendix: source
Thrown at crates/codex-plus-data/src/storage.rs:1012
) -> anyhow::Result<PathBuf> {
let source_db = backup["source_db"]
.as_str()
.filter(|path| !path.trim().is_empty())
.map(PathBuf::from)
.unwrap_or_else(|| fallback_db_path.to_path_buf());
if !source_db.is_file() {
anyhow::bail!(
"Backup source database not found: {}",
source_db.to_string_lossy()
);
}
let source_db = fs::canonicalize(source_db)?;
let allowed = allowed_db_paths
.iter()
.filter_map(|path| fs::canonicalize(path).ok())
.any(|path| path == source_db);
if !allowed {
anyhow::bail!("Backup source database is not an allowed local storage path");
}
Ok(source_db)
}
fn schema_kind(db: &Connection) -> anyhow::Result<Option<SchemaKind>> {
if has_table(db, "sessions")? && has_columns(db, "sessions", &["id", "title"])? {
if has_table(db, "messages")? && !has_columns(db, "messages", &["session_id"])? {
return Ok(None);
}
return Ok(Some(SchemaKind::GenericSessions));
}
if has_table(db, "threads")? && has_columns(db, "threads", &["id", "title", "rollout_path"])? {
return Ok(Some(SchemaKind::CodexThreads));
}
if has_table(db, "automation_runs")? && has_columns(db, "automation_runs", &["thread_id"])? {
return Ok(Some(SchemaKind::CodexAutomationRuns));
}
Ok(None)View on GitHub (pinned to b1ed92e5e4)