{"record":{"id":"2f18711322041722","repo":"Hmbown/CodeWhale","slug":"too-many-notification-events","errorCode":null,"errorMessage":"too many notification events","messagePattern":"too many notification events","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/config/src/notifications.rs","lineNumber":311,"sourceCode":"        }\n    }\n    pub fn validate(&self) -> Result<()> {\n        match self {\n            Self::ThresholdSecs(v) | Self::EventSoundMinIntervalMs(v) => anyhow::ensure!(\n                *v <= i64::MAX as u64,\n                \"notification integer exceeds TOML range\"\n            ),\n            Self::SoundFile(path) => {\n                let value = path.to_str().context(\"sound path must be UTF-8\")?;\n                anyhow::ensure!(\n                    !value.is_empty()\n                        && value.len() <= 4096\n                        && !value.chars().any(char::is_control),\n                    \"invalid sound path\"\n                );\n            }\n            Self::EventSoundEvents(events) => {\n                anyhow::ensure!(events.len() <= 6, \"too many notification events\");\n                for (index, event) in events.iter().enumerate() {\n                    anyhow::ensure!(\n                        NotificationEvent::parse(event).is_some()\n                            && !events[..index].contains(event),\n                        \"invalid or duplicate notification event\"\n                    );\n                }\n            }\n            _ => (),\n        }\n        Ok(())\n    }\n    pub fn value(&self) -> Result<Option<toml::Value>> {\n        self.validate()?;\n        Ok(Some(match self {\n            Self::Method(value) => value.as_str().into(),\n            Self::Sound(Some(value)) | Self::CompletionSound(value) => value.as_str().into(),\n            Self::Sound(None) => return Ok(None),","sourceCodeStart":293,"sourceCodeEnd":329,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/config/src/notifications.rs#L293-L329","documentation":"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.","triggerScenarios":"Constructing NotificationConfigUpdate::EventSoundEvents(vec) with more than 6 entries and calling validate() via value(), persist_for_profile(), edit_extras(), or apply_update().","commonSituations":"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.","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."],"exampleFix":"// before\nlet update = NotificationConfigUpdate::EventSoundEvents(all_seven_events);\n// after\nlet update = NotificationConfigUpdate::EventSoundEvents(all_seven_events.into_iter().take(6).collect());","handlingStrategy":"validation","validationCode":"fn valid_event_count(events: &[String]) -> bool { events.len() <= 6 }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Truncate programmatic lists to 6 before constructing the update","Deduplicate before counting","Fail early in generators rather than at validate time"],"tags":["config","limit"],"backgroundTag":"value-out-of-range","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}