nikivdev/code · error
archive message cannot be empty
Error message
archive message cannot be empty
What it means
Thrown by archive.rs run when the user-supplied archive message trims to an empty string. The message doubles as the archive's slug/name, so an empty one is invalid before any filesystem work starts.
Source
Thrown at src/archive.rs:22
use anyhow::{Context, Result, bail};
use chrono::Local;
use crate::ai_context;
use crate::cli::ArchiveOpts;
pub fn run(opts: ArchiveOpts) -> Result<()> {
let root =
ai_context::find_project_root().ok_or_else(|| anyhow::anyhow!("project root not found"))?;
let root = fs::canonicalize(&root).unwrap_or(root);
let project_name = root
.file_name()
.and_then(|name| name.to_str())
.filter(|name| !name.trim().is_empty())
.unwrap_or("project");
let message = opts.message.trim();
if message.is_empty() {
bail!("archive message cannot be empty");
}
let slug = sanitize_segment(message);
if slug.is_empty() {
bail!("archive message must include at least one letter or number");
}
let home = dirs::home_dir()
.ok_or_else(|| anyhow::anyhow!("could not resolve home directory"))?
.to_path_buf();
let archive_root = home.join("archive").join("code");
fs::create_dir_all(&archive_root).with_context(|| {
format!(
"failed to create archive directory {}",
archive_root.display()
)
})?;
let code_root = fs::canonicalize(home.join("code")).unwrap_or_else(|_| home.join("code"));View on GitHub (pinned to a747e741ae)
Solutions
- Pass a non-empty message: `--message "my archive note"`
- If scripted, guard the variable before calling, e.g. require MSG to be non-empty
- Omit the flag if the tool supports falling back to the default name 'project' — but note an all-whitespace value still fails
Example fix
// before
archive --message "$MSG" # MSG is empty
// after
archive --message "${MSG:-snapshot}" # ensure a non-empty default Defensive patterns
Strategy: validation
Validate before calling
let msg = opts.message.trim();
if msg.is_empty() {
return Err("archive message cannot be empty".into());
} Try / catch
match archive::run(opts) {
Err(e) if e.to_string().contains("message cannot be empty") => {
eprintln!("Provide a non-empty --message.");
std::process::exit(2);
}
other => other,
} Prevention
- Validate the message flag in shell scripts before invoking (e.g. : "${MSG:?empty}")
- Never interpolate possibly-empty variables into --message
- Give the message a sensible default in wrappers
When it happens
Trigger: Invoking the archive command with --message "" or only whitespace (e.g. `--message " "`).
Common situations: Scripting the archive command with an empty shell variable (`--message "$MSG"` when MSG is unset); forgetting the message flag when it has no default.
Related errors
- agent run requires a non-empty query
- archive message must include at least one letter or number
- No prompt provided. Usage: f agents run {} "your prompt here
- unsupported codex open action: {}
- prompt is empty
AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01).
Data as JSON: /api/errors/384b6ea946a2a1f1.
Report an issue: GitHub.