{"record":{"id":"56046ad1926df89c","repo":"kgretzky/evilginx2","slug":"unknown-time-duration-type-s-you-can-use-only","errorCode":null,"errorMessage":"unknown time duration type: '%s', you can use only 'd', 'h', 'm' or 's'","messagePattern":"unknown time duration type: '(.+?)', you can use only 'd', 'h', 'm' or 's'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/utils.go","lineNumber":120,"sourceCode":"\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\t\t\t\t\t\tswitch c {\n\t\t\t\t\t\tcase 'd':\n\t\t\t\t\t\t\tdays = val\n\t\t\t\t\t\tcase 'h':\n\t\t\t\t\t\t\thours = val\n\t\t\t\t\t\tcase 'm':\n\t\t\t\t\t\t\tminutes = val\n\t\t\t\t\t\tcase 's':\n\t\t\t\t\t\t\tseconds = val\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\terr = fmt.Errorf(\"you can only use time duration types in following order: 'd' > 'h' > 'm' > 's'\")\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\terr = fmt.Errorf(\"unknown time duration type: '%s', you can use only 'd', 'h', 'm' or 's'\", string(c))\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = fmt.Errorf(\"time duration value needs to start with a number\")\n\t\t\t\treturn\n\t\t\t}\n\t\t\ts_num = \"\"\n\t\t}\n\t}\n\tt_dur = time.Duration(days)*24*time.Hour + time.Duration(hours)*time.Hour + time.Duration(minutes)*time.Minute + time.Duration(seconds)*time.Second\n\treturn\n}\n\nfunc GetDurationString(t_now time.Time, t_expire time.Time) (ret string) {\n\tvar days, hours, minutes, seconds int64\n\tret = \"\"\n\n\tif t_expire.After(t_now) {","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/kgretzky/evilginx2/blob/4c0988a1d9db4d172a185e979a38bfd0efdb5830/core/utils.go#L102-L138","documentation":"ParseDurationString only recognizes the unit characters 'd', 'h', 'm' and 's'. When it encounters a non-digit character that is not one of these units (after having accumulated a number), it returns this error naming the offending character.","triggerScenarios":"Including unsupported unit letters or stray symbols in the duration string, e.g. '5w', '2h30min', '1d 5h' (the space triggers it), '3x'.","commonSituations":"Using Go-style units like 'ms', 'us', 'ns' or 'w' for weeks, pasting durations with spaces, writing 'min' instead of 'm'.","solutions":["Use only 'd', 'h', 'm', 's' units: '2h30m' not '2h30min'.","Remove spaces and punctuation from the duration string.","Convert other units first, e.g. weeks to days: '2w' → '14d'."],"exampleFix":"// before\nParseDurationString(\"2h30min\")\n// after\nParseDurationString(\"2h30m\")","handlingStrategy":"validation","validationCode":"var durRe = regexp.MustCompile(`^\\d+(?:[dhms]\\d+)*[dhms]?$`)\nif !durRe.MatchString(durStr) {\n    return fmt.Errorf(\"duration %q may only contain digits and units d/h/m/s\", durStr)\n}\nd, err := core.ParseDurationString(durStr)","typeGuard":"func hasOnlyKnownUnits(s string) bool {\n    for _, c := range s {\n        if (c < '0' || c > '9') && !strings.ContainsRune(\"dhms\", c) {\n            return false\n        }\n    }\n    return len(s) > 0\n}","tryCatchPattern":"d, err := core.ParseDurationString(input)\nif err != nil {\n    if strings.Contains(err.Error(), \"unknown time duration type\") {\n        log.Printf(\"unsupported unit in %q; only d, h, m, s allowed\", input)\n        return\n    }\n    return err\n}","preventionTips":["Convert other units first: weeks→days, minutes written as m not min","Strip spaces and symbols from duration input","Reuse one regex validator at every duration input site"],"tags":["parsing","duration","validation"],"backgroundTag":"invalid-duration-format","analyzedSha":"4c0988a1d9db4d172a185e979a38bfd0efdb5830","analyzedAt":"2026-09-05T19:23:07.238Z","contentChangedAt":"2026-09-05T19:23:07.238Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}