From 4cf428a1cd173b63c1308479635ce2869a1386af Mon Sep 17 00:00:00 2001 From: Stefan Wallentowitz Date: Fri, 1 Nov 2024 14:15:02 +0100 Subject: [PATCH] Raise warning for potentially malformed student If you miss the space after the hyphen in them yaml list of students, it will siltenty assume another list format during unmarshaling and have each of the items with the hypen (not even sure if this is correct or should fail instead). Raise a warning as this could be a mistake. I don't think there is much common use of either mail, id or username starting with a hyphen, so I think its fair to raise a warning. --- config/students.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/config/students.go b/config/students.go index 5e248f3..56a3e4a 100644 --- a/config/students.go +++ b/config/students.go @@ -78,6 +78,11 @@ func mkStudents(studs []string) []*Student { for _, stud := range studs { rawStud := stud student := &Student{Raw: rawStud} + + if strings.HasPrefix(stud, "-") { + log.Warn().Str("student in config", stud).Msg("student identifier starts with '-', did you miss the space after hyphen?") + } + // E-Mail? if ev.NewSyntaxValidator().Validate(ev.NewInput(evmail.FromString(stud))).IsValid() { log.Debug().Str("student in config", stud).Msg("is valid email")