@@ -33,29 +33,44 @@ pub(super) async fn validate_config(
3333 let triagebot_content = triagebot_content. unwrap_or_default ( ) ;
3434 let triagebot_content = String :: from_utf8_lossy ( & * triagebot_content) ;
3535
36- let Err ( e) = toml:: from_str :: < crate :: handlers:: Config > ( & triagebot_content) else {
37- return Ok ( None ) ;
38- } ;
36+ match toml:: from_str :: < crate :: handlers:: Config > ( & triagebot_content) {
37+ Err ( e) => {
38+ let position = match e. span ( ) {
39+ // toml sometimes gives bad spans, see https://github.com/toml-rs/toml/issues/589
40+ Some ( span) if span != ( 0 ..0 ) => {
41+ let ( line, col) = translate_position ( & triagebot_content, span. start ) ;
42+ let url = format ! (
43+ "https://github.com/{}/blob/{}/{CONFIG_FILE_NAME}#L{line}" ,
44+ repo. full_name, pr_source. sha
45+ ) ;
46+ format ! ( " at position [{line}:{col}]({url})" , )
47+ }
48+ Some ( _) | None => String :: new ( ) ,
49+ } ;
3950
40- let position = match e. span ( ) {
41- // toml sometimes gives bad spans, see https://github.com/toml-rs/toml/issues/589
42- Some ( span) if span != ( 0 ..0 ) => {
43- let ( line, col) = translate_position ( & triagebot_content, span. start ) ;
44- let url = format ! (
45- "https://github.com/{}/blob/{}/{CONFIG_FILE_NAME}#L{line}" ,
46- repo. full_name, pr_source. sha
47- ) ;
48- format ! ( " at position [{line}:{col}]({url})" , )
51+ Ok ( Some ( format ! (
52+ "Invalid `triagebot.toml`{position}:\n \
53+ `````\n \
54+ {e}\n \
55+ `````",
56+ ) ) )
4957 }
50- Some ( _) | None => String :: new ( ) ,
51- } ;
58+ Ok ( config) => {
59+ // Error if `[assign.owners]` is not empty (ie auto-assign) and the custom welcome message for assignee isn't set.
60+ if let Some ( assign) = config. assign
61+ && !assign. owners . is_empty ( )
62+ && let Some ( custom_welcome_messages) = & assign. custom_welcome_messages
63+ && custom_welcome_messages. welcome_message . is_none ( )
64+ {
65+ return Ok ( Some (
66+ "Invalid `triagebot.toml`:\n \
67+ `[assign.owners]` is populated but `[assign.custom_welcome_messages.welcome-message]` is not set!". to_string ( )
68+ ) ) ;
69+ }
5270
53- Ok ( Some ( format ! (
54- "Invalid `triagebot.toml`{position}:\n \
55- `````\n \
56- {e}\n \
57- `````",
58- ) ) )
71+ Ok ( None )
72+ }
73+ }
5974}
6075
6176/// Helper to translate a toml span to a `(line_no, col_no)` (1-based).
0 commit comments