{"record":{"id":"1901ecc295ad1b32","repo":"goharbor/harbor","slug":"empty-cron-string-is-invalid","errorCode":null,"errorMessage":"empty cron string is invalid","messagePattern":"empty cron string is invalid","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"src/common/utils/utils.go","lineNumber":302,"sourceCode":"\t}\n\tcr := strings.TrimSpace(cron)\n\ts, err := CronParser().Parse(cr)\n\tif err != nil {\n\t\tlog.Debugf(\"the cron string %v is invalid, error: %v\", cron, err)\n\t\treturn time.Time{}\n\t}\n\treturn s.Next(curTime)\n}\n\n// CronParser returns the parser of cron string with format of \"* * * * * *\"\nfunc CronParser() cronlib.Parser {\n\treturn cronlib.NewParser(cronlib.Second | cronlib.Minute | cronlib.Hour | cronlib.Dom | cronlib.Month | cronlib.Dow)\n}\n\n// ValidateCronString check whether it is a valid cron string and whether the 1st field (indicating Seconds of time) of the cron string is a fixed value of 0 or not\nfunc ValidateCronString(cron string) error {\n\tif len(cron) == 0 {\n\t\treturn fmt.Errorf(\"empty cron string is invalid\")\n\t}\n\t_, err := CronParser().Parse(cron)\n\tif err != nil {\n\t\treturn err\n\t}\n\tcronParts := strings.Split(cron, \" \")\n\tif len(cronParts) == 6 && cronParts[0] != \"0\" {\n\t\treturn fmt.Errorf(\"the 1st field (indicating Seconds of time) of the cron setting must be 0\")\n\t}\n\treturn nil\n}\n\n// IsLocalPath checks if path is local, includes the empty path\nfunc IsLocalPath(path string) bool {\n\treturn len(path) == 0 || (strings.HasPrefix(path, \"/\") && !strings.HasPrefix(path, \"//\"))\n}\n","sourceCodeStart":284,"sourceCodeEnd":319,"githubUrl":"https://github.com/goharbor/harbor/blob/7b2fd08cc568955cca339afeefab27372840d936/src/common/utils/utils.go#L284-L319","documentation":"Error \"empty cron string is invalid\" thrown in goharbor/harbor.","triggerScenarios":"Thrown at src/common/utils/utils.go:302 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7b2fd08cc568955cca339afeefab27372840d936","analyzedAt":"2026-08-16T00:00:10.961Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}