From 6267fc0ddb94e3bb0954806cba281e69ec6c0904 Mon Sep 17 00:00:00 2001 From: Urgau Date: Wed, 21 Jan 2026 07:42:49 +0100 Subject: [PATCH] Add validation error when a mentions pattern starts with a `/` --- src/handlers/check_commits/validate_config.rs | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/handlers/check_commits/validate_config.rs b/src/handlers/check_commits/validate_config.rs index c94b83df..395948a9 100644 --- a/src/handlers/check_commits/validate_config.rs +++ b/src/handlers/check_commits/validate_config.rs @@ -71,13 +71,20 @@ pub(super) async fn validate_config( // Error if one the mentions entry is not a valid glob. if let Some(mentions) = config.mentions { for (entry, MentionsEntryConfig { type_, .. }) in mentions.entries { - if type_ == MentionsEntryType::Filename - && let Err(err) = globset::Glob::new(&entry) - { - return Ok(Some(format!( - "Invalid `triagebot.toml`:\n\ - `[mentions.\"{entry}\"]` has an invalid glob syntax: {err}" - ))); + if type_ == MentionsEntryType::Filename { + if let Err(err) = globset::Glob::new(&entry) { + return Ok(Some(format!( + "Invalid `triagebot.toml`:\n\ + `[mentions.\"{entry}\"]` has an invalid glob syntax: {err}" + ))); + } + + if entry.starts_with('/') { + return Ok(Some(format!( + "Invalid `triagebot.toml`:\n\ + `[mentions.\"{entry}\"]` has an invalid pattern: path must be relative (remove the `/` at the start)" + ))); + } } } }