moghtech/komodo · error · anyhow::Error
Password cannot be empty.
Error message
Password cannot be empty.
What it means
set_user_password validates the plaintext password before hashing it and rejects empty strings up front with this error. The library refuses to create an empty password credential because an empty password would be meaningless/unusable for authentication.
Solutions
- Ensure the caller supplies a non-empty password string before invoking the API
- Validate on the UI/form layer that the password field is non-empty (and ideally meets length policy)
- Skip or guard the call in import/migration code when the password is blank
- Return a user-facing 'password required' message instead of passing an empty value through
Example fix
// before
user_password::set(db, &user, form.password.as_deref().unwrap_or("")).await?;
// after
let pw = form.password.as_deref().unwrap_or("");
if pw.is_empty() { bail!("password is required"); }
user_password::set(db, &user, pw).await?; Defensive patterns
Strategy: validation
Validate before calling
fn validate_password(password: &str) -> Result<(), String> {
if password.is_empty() { return Err("password is required".into()); }
if password.len() < 8 { return Err("password too short".into()); }
Ok(())
} Try / catch
match db.set_user_password(&user, &pw).await {
Err(e) if e.to_string() == "Password cannot be empty." => {
return Err(FieldError::new("password", "must not be empty"));
}
other => other,
} Prevention
- Validate non-empty (and length policy) passwords in the UI/CLI before calling the API
- Unwrap optional password form fields explicitly rather than defaulting to ""
- Reject blank password fields in migration/import scripts
When it happens
Trigger: Calling set_user_password with password == "" on a User record.
Common situations: UI or CLI signup flows with missing client-side validation passing an empty string; migration scripts importing users with blank password fields; form submission where the password field was never filled.
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
- Must attach either swarm or server
- Cannot insert Service type configuration as additional…
- Service Users cannot add additional login methods
AI-assisted analysis of moghtech/komodo@780ac68b99 (2026-09-08).
Data as JSON: /api/errors/497cc000f7e1f00b.
Report an issue: GitHub.
Appendix: source
Thrown at lib/database/src/lib.rs:123
procedures: resource_collection(&db, "Procedure").await?,
actions: resource_collection(&db, "Action").await?,
resource_syncs: resource_collection(&db, "ResourceSync")
.await?,
stacks: resource_collection(&db, "Stack").await?,
//
db,
};
Ok(client)
}
/// Updates a user's password using a DB call.
pub async fn set_user_password(
&self,
user: &User,
password: &str,
) -> anyhow::Result<()> {
if password.is_empty() {
return Err(anyhow!("Password cannot be empty."));
}
let hashed_password =
hash_password(password).context("Failed to hash password")?;
self.set_user_hashed_password(user, hashed_password).await
}
/// Updates a user's password using a DB call.
pub async fn set_user_hashed_password(
&self,
user: &User,
hashed_password: String,
) -> anyhow::Result<()> {
let update = match user.config {
UserConfig::Service { .. } => {
return Err(anyhow!(
"Service Users cannot add additional login methods"
));
}View on GitHub (pinned to 780ac68b99)