Hmbown/CodeWhale · warning · io::Error
Session title cannot be empty
Error message
Session title cannot be empty
What it means
normalize_session_title sanitizes a user-supplied title and rejects the result if it is empty after trimming, with an InvalidInput io::Error. The library throws this because an empty title would make sessions unidentifiable in the picker and API surfaces that all funnel through this shared validator.
Solutions
- Provide a non-empty title with at least one visible character after trimming.
- If sanitization strips the content, choose characters the sanitizer preserves (letters, digits, common punctuation).
- On the API/UI side, validate client-side that the trimmed title is non-empty before calling rename.
Example fix
// before
let title = normalize_session_title(" ")?; // InvalidInput
// after
let raw = input.trim();
if raw.is_empty() { anyhow::bail!("please enter a session title"); }
let title = normalize_session_title(raw)?; Defensive patterns
Strategy: validation
Validate before calling
fn title_ok(t: &str) -> bool {
!t.trim().is_empty()
} Try / catch
match normalize_session_title(input) {
Err(e) if e.kind() == std::io::ErrorKind::InvalidInput => {
eprintln!("title rejected: {e}");
Err(e)
}
other => other,
} Prevention
- Trim and check non-empty in UI/API layers before calling rename.
- Respect MAX_SESSION_TITLE_CHARS when collecting input.
- Remember sanitization can strip characters — ensure at least one survives.
When it happens
Trigger: Calling normalize_session_title (directly or via rename flows: picker rename, /rename command, PATCH /v1/sessions/{id}) with a title that is empty, whitespace-only, or becomes empty after sanitization strips all characters (e.g. only control/formatting characters).
Common situations: Submitting an empty rename form, sending {"title": " "} to the HTTP API, or a title consisting solely of characters the sanitizer removes.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- base URL cannot be empty
- browser URL cannot be empty
- classifier-approved read command was empty
- Codewhale runtime event file is empty.
- CRON field must not be empty
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/c88103c7d8509979.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/session_manager.rs:3003
/// OSC 0 terminal title, `codewhale sessions` stdout, and the picker, so the
/// persisted value must not be able to carry a raw escape sequence. Ordinary
/// text, punctuation, CJK, and emoji pass through untouched.
pub fn sanitize_session_title(raw: &str) -> String {
raw.chars()
.filter(|ch| !ch.is_control() && !is_title_format_char(*ch))
.collect()
}
/// Sanitize, trim, and bound a user-supplied session title.
///
/// Returns `InvalidInput` for an empty title or one longer than
/// [`MAX_SESSION_TITLE_CHARS`] so every rename surface (picker, `/rename`,
/// `PATCH /v1/sessions/{id}`) rejects the same inputs with the same reason.
pub fn normalize_session_title(title: &str) -> std::io::Result<String> {
let sanitized = sanitize_session_title(title);
let trimmed = sanitized.trim();
if trimmed.is_empty() {
return Err(std::io::Error::new(
std::io::ErrorKind::InvalidInput,
"Session title cannot be empty",
));
}
if trimmed.chars().count() > MAX_SESSION_TITLE_CHARS {
return Err(std::io::Error::new(
std::io::ErrorKind::InvalidInput,
format!("Session title cannot exceed {MAX_SESSION_TITLE_CHARS} characters"),
));
}
Ok(trimmed.to_string())
}
pub(crate) fn workspace_scope_matches(saved_workspace: &Path, current_workspace: &Path) -> bool {
if paths_equivalent(saved_workspace, current_workspace) {
return true;
}
View on GitHub (pinned to 73e0f67d83)