{"record":{"id":"2731f33b735f282e","repo":"SigNoz/signoz","slug":"couldn-t-generate-layout-regex-for-time-parser-s","errorCode":null,"errorMessage":"couldn't generate layout regex for time_parser %s: %w","messagePattern":"couldn't generate layout regex for time_parser (.+?): %w","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"pkg/query-service/app/logparsingpipeline/pipelineBuilder.go","lineNumber":176,"sourceCode":"\t\t\t\t\t\t\"couldn't generate nil check for field to be removed by op %s: %w\", operator.Name, err,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\toperator.If = fieldNotNilCheck\n\t\t\t} else if operator.Type == \"trace_parser\" {\n\t\t\t\tcleanTraceParser(&operator)\n\t\t\t} else if operator.Type == \"time_parser\" {\n\t\t\t\tparseFromNotNilCheck, err := fieldNotNilCheck(operator.ParseFrom)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, fmt.Errorf(\n\t\t\t\t\t\t\"couldn't generate nil check for parseFrom of time parser op %s: %w\", operator.Name, err,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\toperator.If = parseFromNotNilCheck\n\n\t\t\t\tif operator.LayoutType == \"strptime\" {\n\t\t\t\t\tregex, err := pipelinetypes.RegexForStrptimeLayout(operator.Layout)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, fmt.Errorf(\n\t\t\t\t\t\t\t\"couldn't generate layout regex for time_parser %s: %w\", operator.Name, err,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\n\t\t\t\t\toperator.If = fmt.Sprintf(\n\t\t\t\t\t\t`%s && %s matches \"%s\"`, operator.If, operator.ParseFrom, regex,\n\t\t\t\t\t)\n\t\t\t\t} else if operator.LayoutType == \"epoch\" {\n\t\t\t\t\tvalueRegex := `^\\\\s*[0-9]+\\\\s*$`\n\t\t\t\t\tif strings.Contains(operator.Layout, \".\") {\n\t\t\t\t\t\tvalueRegex = `^\\\\s*[0-9]+\\\\.[0-9]+\\\\s*$`\n\t\t\t\t\t}\n\n\t\t\t\t\toperator.If = fmt.Sprintf(\n\t\t\t\t\t\t`%s && string(%s) matches \"%s\"`, operator.If, operator.ParseFrom, valueRegex,\n\t\t\t\t\t)\n\n\t\t\t\t}","sourceCodeStart":158,"sourceCodeEnd":194,"githubUrl":"https://github.com/SigNoz/signoz/blob/5069bf80b08f1f00d7e014eccc09902f9871004f/pkg/query-service/app/logparsingpipeline/pipelineBuilder.go#L158-L194","documentation":"When a time_parser uses layout_type \"strptime\", SigNoz converts the strptime layout string into a regular expression (RegexForStrptimeLayout) to strengthen the `if` condition. This error means that conversion failed, i.e. the layout string contains unsupported or malformed strptime directives. The pipeline is rejected during getOperators/PreparePipelineProcessor.","triggerScenarios":"{\"type\":\"time_parser\",\"layout_type\":\"strptime\",\"layout\":\"%Y-%m-%d %h:%m\"} with an unrecognized directive (e.g. %h is not a valid strptime token), stray '%', or an empty layout. RegexForStrptimeLayout returns an error which is wrapped here with the operator name.","commonSituations":"Mixing Go reference-time layouts (2006-01-02) with strptime (%Y-%m-%d); typos in directives; using layout_type strptime when the value is actually a named layout like RFC3339; upgrading versions where the allowed directive set changed.","solutions":["Correct the strptime layout to use only supported directives (%Y %m %d %H %M %S %z etc.)","If the timestamp is RFC3339/ISO, use the named-layout option instead of strptime","Test the layout against sample timestamps with date -j -f or strftime before submitting"],"exampleFix":"// before\n{\"layout_type\":\"strptime\",\"layout\":\"2006-01-02 15:04\"}\n// after\n{\"layout_type\":\"strptime\",\"layout\":\"%Y-%m-%d %H:%M\"}","handlingStrategy":"validation","validationCode":"var strptimeDirectiveRe = regexp.MustCompile(`%[-_0^#]?[a-zA-Z]`)\nvar okDirectives = map[string]bool{\"Y\":true,\"m\":true,\"d\":true,\"H\":true,\"M\":true,\"S\":true,\"z\":true,\"Z\":true,\"b\":true,\"B\":true,\"e\":true,\"f\":true,\"p\":true,\"I\":true,\"j\":true,\"y\":true,\"T\":true}\nfunc validStrptime(l string) bool {\n  for _, m := range strptimeDirectiveRe.FindAllString(l, -1) {\n    d := strings.TrimLeft(m, \"%-_0^#\")\n    if !okDirectives[strings.TrimPrefix(d, \"%\")] { return false }\n  }\n  return true\n}","typeGuard":"func isStrptimeLayoutValid(layout, layoutType string) bool { return layoutType != \"strptime\" || validStrptime(layout) }","tryCatchPattern":"On error, prompt the user to re-enter the layout; validate with time.Parse against a sample timestamp before submit.","preventionTips":["Never mix Go layout tokens (2006, 01, 02) with strptime tokens","Prefer named layouts (RFC3339) for ISO timestamps","Test layouts in the UI preview before saving"],"tags":["signoz","log-parsingpipeline","strptime","time-format"],"backgroundTag":"invalid-datetime-format","analyzedSha":"5069bf80b08f1f00d7e014eccc09902f9871004f","analyzedAt":"2026-08-28T06:22:12.824Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}