gitbutlerapp/gitbutler · error
Suppression duration must be at least 1 hour
Error message
Suppression duration must be at least 1 hour
What it means
`suppress_update` in but-update's cache module validates the requested auto-update suppression duration before persisting it. A value of 0 hours is meaningless (nothing would be suppressed) and is rejected immediately with this bail!.
Solutions
- Pass a duration of at least 1 hour, e.g. `suppress_update(cache, 1)`.
- Clamp the computed value before calling: `let hours = hours.max(1);`.
- Fix the caller that produces 0 (default the UI selector to a sane minimum like 24h).
Example fix
// before suppress_update(&mut cache, user_hours).await?; // after suppress_update(&mut cache, user_hours.max(1)).await?;
Defensive patterns
Strategy: validation
Validate before calling
if hours == 0 { return Err("suppression must be at least 1 hour"); }
suppress_update(&mut cache, hours)?; Try / catch
// Rust
match suppress_update(&mut cache, hours) {
Err(e) if e.to_string().contains("at least 1 hour") => {
eprintln!("choose a duration >= 1h");
}
r => r?,
} Prevention
- Clamp computed durations with `.max(1)` before calling.
- Default UI selectors to a positive minimum (e.g. 24h).
- Validate stored preferences on load and discard zero values.
When it happens
Trigger: Calling `suppress_update(cache, 0)`, or a UI/config path that computes a 0-hour duration (e.g. an expired or zero-valued "remind me later" setting).
Common situations: A settings dialog defaulting to 0 before the user picks a value; computing hours from timestamps that yield 0; deserializing a stored suppression preference of `0`.
Understand the failure class
Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.
Related errors
- Suppression duration cannot exceed
- Aborting due to empty branch name
- Aborting due to empty
- API returned version
- At least one review number is required
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/9b05493d97875cb4.
Report an issue: GitHub.
Appendix: source
Thrown at crates/but-update/src/cache.rs:126
/// * `Err(_)` - An error occurred:
/// - Invalid hours value (must be 1-720)
/// - No cached update check exists
/// - The cached status shows the app is already up to date
/// - Failed to write the updated cache
///
/// # Errors
///
/// Returns an error if:
/// - The hours parameter is 0 or greater than 720 (30 days)
/// - No update check has been performed yet (no cache exists)
/// - The current version is already up to date (nothing to suppress)
/// - The cache cannot be written
pub fn suppress_update(cache: &mut but_db::AppCacheHandle, hours: u32) -> anyhow::Result<()> {
// Validate input
const MAX_SUPPRESSION_HOURS: u32 = 720; // 30 days
if hours == 0 {
anyhow::bail!("Suppression duration must be at least 1 hour");
}
if hours > MAX_SUPPRESSION_HOURS {
anyhow::bail!("Suppression duration cannot exceed {MAX_SUPPRESSION_HOURS} hours (30 days)");
}
cache
.update_check_mut()?
.suppress(hours)
.map_err(Into::into)
}
View on GitHub (pinned to 58e5313667)