{"record":{"id":"7c3ab65ff1c2d33a","repo":"crowdsecurity/crowdsec","slug":"unable-to-parse-time","errorCode":null,"errorMessage":"unable to parse time","messagePattern":"unable to parse time","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/database/errors.go","lineNumber":14,"sourceCode":"package database\n\nimport \"errors\"\n\nvar (\n\tUserExists        = errors.New(\"user already exist\")\n\tUserNotExists     = errors.New(\"user doesn't exist\")\n\tHashError         = errors.New(\"unable to hash\")\n\tInsertFail        = errors.New(\"unable to insert row\")\n\tQueryFail         = errors.New(\"unable to query\")\n\tUpdateFail        = errors.New(\"unable to update\")\n\tDeleteFail        = errors.New(\"unable to delete\")\n\tItemNotFound      = errors.New(\"object not found\")\n\tParseTimeFail     = errors.New(\"unable to parse time\")\n\tParseDurationFail = errors.New(\"unable to parse duration\")\n\tMarshalFail       = errors.New(\"unable to serialize\")\n\tBulkError         = errors.New(\"unable to insert bulk\")\n\tParseType         = errors.New(\"unable to parse type\")\n\tInvalidIPOrRange  = errors.New(\"invalid ip address / range\")\n\tInvalidFilter     = errors.New(\"invalid filter\")\n)\n","sourceCodeStart":1,"sourceCodeEnd":22,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/database/errors.go#L1-L22","documentation":"ParseTimeFail is a sentinel error meaning an RFC3339 timestamp string could not be parsed by time.Parse. In crowdsec it surfaces when alert start_at/stop_at fields submitted to CreateAlert lack the RFC3339 format (e.g. missing timezone offset).","triggerScenarios":"CreateAlert (via UpdateCommunityBlocklist or alert ingestion) when alertItem.StartAt or alertItem.StopAt is not a valid RFC3339 string, e.g. \"2024-01-01 10:00:00\" instead of \"2024-01-01T10:00:00Z\".","commonSituations":"Custom automation or bouncers posting alerts with locally formatted dates, hand-written JSON payloads without the 'T' separator or timezone, clients in non-UTC environments dropping the offset.","solutions":["Format timestamps with time.RFC3339 (time.Now().Format(time.RFC3339)) before submitting.","Ensure the string uses 'T' separator and an explicit offset/Z: convert with time.Parse then re-format.","If ingesting third-party JSON, normalize the date field before calling the client API.","Log the offending value (already included in the wrapped error) and correct the producer."],"exampleFix":"// before\nalert.StartAt = ptr(\"2024-05-01 12:00:00\")\n// after\nalert.StartAt = ptr(time.Now().UTC().Format(time.RFC3339))","handlingStrategy":"validation","validationCode":"func validRFC3339(s string) bool {\n    _, err := time.Parse(time.RFC3339, s)\n    return err == nil\n}\n// call before submitting: validRFC3339(alert.StartAt)","typeGuard":null,"tryCatchPattern":"if _, _, _, err := client.CreateAlert(ctx, alert); err != nil {\n    if errors.Is(err, database.ParseTimeFail) {\n        return fmt.Errorf(\"fix start_at/stop_at to RFC3339: %w\", err)\n    }\n    return err\n}","preventionTips":["Always generate timestamps with time.Now().Format(time.RFC3339)","Validate date fields at API boundaries before calling the database layer","Reject naive (offset-less) datetime strings at producer level"],"tags":["database","crowdsec","time","parsing"],"backgroundTag":"invalid-date-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"}