{"record":{"id":"6e1218ff9e3dc875","repo":"crowdsecurity/crowdsec","slug":"while-parsing-agents-login-password-auto-delete-du","errorCode":null,"errorMessage":"while parsing agents login/password auto-delete duration: %w","messagePattern":"while parsing agents login/password auto-delete duration: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/database/flush.go","lineNumber":81,"sourceCode":"\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"while starting FlushAlerts scheduler: %w\", err)\n\t}\n\n\t// Init & Start cronjob every hour for bouncers/agents\n\tif config.AgentsGC != nil {\n\t\tif config.AgentsGC.Cert != nil {\n\t\t\tduration, err := cstime.ParseDurationWithDays(*config.AgentsGC.Cert)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"while parsing agents cert auto-delete duration: %w\", err)\n\t\t\t}\n\n\t\t\tconfig.AgentsGC.CertDuration = &duration\n\t\t}\n\n\t\tif config.AgentsGC.LoginPassword != nil {\n\t\t\tduration, err := cstime.ParseDurationWithDays(*config.AgentsGC.LoginPassword)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"while parsing agents login/password auto-delete duration: %w\", err)\n\t\t\t}\n\n\t\t\tconfig.AgentsGC.LoginPasswordDuration = &duration\n\t\t}\n\n\t\tif config.AgentsGC.Api != nil {\n\t\t\tc.Log.Warning(\"agents auto-delete for API auth is not supported (use cert or login_password)\")\n\t\t}\n\t}\n\n\tif config.BouncersGC != nil {\n\t\tif config.BouncersGC.Cert != nil {\n\t\t\tduration, err := cstime.ParseDurationWithDays(*config.BouncersGC.Cert)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"while parsing bouncers cert auto-delete duration: %w\", err)\n\t\t\t}\n\n\t\t\tconfig.BouncersGC.CertDuration = &duration","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/database/flush.go#L63-L99","documentation":"StartFlushScheduler parses the agents_gc.login_password duration with cstime.ParseDurationWithDays. When the configured string cannot be parsed as a duration-with-days, this wrapped error is returned and startup fails.","triggerScenarios":"config.AgentsGC.LoginPassword contains an unparseable value — unitless number, unsupported unit ('mo', 'y'), or malformed string.","commonSituations":"Operator writes login_password: 1 year or login_password: 2w in api.server.gc.agents_gc; values copied from older docs that used different syntax.","solutions":["Correct the value in config.yaml to a valid Go duration or day form, e.g. login_password: 30d or login_password: 720h.","Avoid unsupported units; only Go duration units plus 'd' are accepted.","Remove the key to disable login/password GC for agents.","Test the duration string with cstime.ParseDurationWithDays semantics before deploying (days count 24h each)."],"exampleFix":"// before\nagents_gc:\n  login_password: 1 year\n\n// after\nagents_gc:\n  login_password: 365d","handlingStrategy":"validation","validationCode":"if cfg.AgentsGC != nil && cfg.AgentsGC.LoginPassword != \"\" {\n    if _, err := cstime.ParseDurationWithDays(cfg.AgentsGC.LoginPassword); err != nil {\n        return fmt.Errorf(\"agents_gc.login_password: %w\", err)\n    }\n}","typeGuard":null,"tryCatchPattern":"if err != nil {\n    if strings.Contains(err.Error(), \"agents login/password\") {\n        // surface the offending config key to the operator\n    }\n    return err\n}","preventionTips":["Convert human units (weeks, months, years) into days or hours before writing them to config.","Keep gc durations in one documented unit style across the config file.","Lint config values in CI using ParseDurationWithDays."],"tags":["go","config","duration","crowdsec"],"backgroundTag":"invalid-duration-format","analyzedSha":"909b5157986a2b2c2163300fdaef5ed01289f7d2","analyzedAt":"2026-09-06T12:27:26.012Z","contentChangedAt":"2026-09-06T12:27:26.012Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}