Hmbown/CodeWhale · error
too many notification events
Error message
too many notification events
What it means
This error is thrown by NotificationConfigUpdate::validate when an EventSoundEvents list contains more than 6 event names. It is the validate-side counterpart of the parse-time cap ("too many notification event names"), enforcing the same bound on values constructed directly in Rust.
Solutions
- Truncate or prioritize the list to at most 6 events before constructing the update.
- Deduplicate first — duplicates count toward the cap.
- Use the global EventSoundEnabled/EventSoundQuiet settings instead of enumerating many events.
- Reject oversized selections at the UI/generator level with a clear message.
Example fix
// before let update = NotificationConfigUpdate::EventSoundEvents(all_seven_events); // after let update = NotificationConfigUpdate::EventSoundEvents(all_seven_events.into_iter().take(6).collect());
Defensive patterns
Strategy: validation
Validate before calling
fn valid_event_count(events: &[String]) -> bool { events.len() <= 6 } Prevention
- Truncate programmatic lists to 6 before constructing the update
- Deduplicate before counting
- Fail early in generators rather than at validate time
When it happens
Trigger: Constructing NotificationConfigUpdate::EventSoundEvents(vec) with more than 6 entries and calling validate() via value(), persist_for_profile(), edit_extras(), or apply_update().
Common situations: Programmatic config generation appends event names without a cap; a UI lets users select unlimited events; aggregated lists from multiple sources are merged without truncation.
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
- MCP config exceeds the 1 MiB limit
- MCP consent history exceeds size limit
- project config exceeds the 1 MiB limit
- project hooks file exceeds the 1 MiB limit
- too many notification event names
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/2f18711322041722.
Report an issue: GitHub.
Appendix: source
Thrown at crates/config/src/notifications.rs:311
}
}
pub fn validate(&self) -> Result<()> {
match self {
Self::ThresholdSecs(v) | Self::EventSoundMinIntervalMs(v) => anyhow::ensure!(
*v <= i64::MAX as u64,
"notification integer exceeds TOML range"
),
Self::SoundFile(path) => {
let value = path.to_str().context("sound path must be UTF-8")?;
anyhow::ensure!(
!value.is_empty()
&& value.len() <= 4096
&& !value.chars().any(char::is_control),
"invalid sound path"
);
}
Self::EventSoundEvents(events) => {
anyhow::ensure!(events.len() <= 6, "too many notification events");
for (index, event) in events.iter().enumerate() {
anyhow::ensure!(
NotificationEvent::parse(event).is_some()
&& !events[..index].contains(event),
"invalid or duplicate notification event"
);
}
}
_ => (),
}
Ok(())
}
pub fn value(&self) -> Result<Option<toml::Value>> {
self.validate()?;
Ok(Some(match self {
Self::Method(value) => value.as_str().into(),
Self::Sound(Some(value)) | Self::CompletionSound(value) => value.as_str().into(),
Self::Sound(None) => return Ok(None),View on GitHub (pinned to 73e0f67d83)