SigNoz/signoz · error
couldn't generate layout regex for time_parser %s: %w
Error message
couldn't generate layout regex for time_parser %s: %w
What it means
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.
Source
Thrown at pkg/query-service/app/logparsingpipeline/pipelineBuilder.go:176
"couldn't generate nil check for field to be removed by op %s: %w", operator.Name, err,
)
}
operator.If = fieldNotNilCheck
} else if operator.Type == "trace_parser" {
cleanTraceParser(&operator)
} else if operator.Type == "time_parser" {
parseFromNotNilCheck, err := fieldNotNilCheck(operator.ParseFrom)
if err != nil {
return nil, fmt.Errorf(
"couldn't generate nil check for parseFrom of time parser op %s: %w", operator.Name, err,
)
}
operator.If = parseFromNotNilCheck
if operator.LayoutType == "strptime" {
regex, err := pipelinetypes.RegexForStrptimeLayout(operator.Layout)
if err != nil {
return nil, fmt.Errorf(
"couldn't generate layout regex for time_parser %s: %w", operator.Name, err,
)
}
operator.If = fmt.Sprintf(
`%s && %s matches "%s"`, operator.If, operator.ParseFrom, regex,
)
} else if operator.LayoutType == "epoch" {
valueRegex := `^\\s*[0-9]+\\s*$`
if strings.Contains(operator.Layout, ".") {
valueRegex = `^\\s*[0-9]+\\.[0-9]+\\s*$`
}
operator.If = fmt.Sprintf(
`%s && string(%s) matches "%s"`, operator.If, operator.ParseFrom, valueRegex,
)
}View on GitHub (pinned to 5069bf80b0)
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
Example fix
// before
{"layout_type":"strptime","layout":"2006-01-02 15:04"}
// after
{"layout_type":"strptime","layout":"%Y-%m-%d %H:%M"} Defensive patterns
Strategy: validation
Validate before calling
var strptimeDirectiveRe = regexp.MustCompile(`%[-_0^#]?[a-zA-Z]`)
var 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}
func validStrptime(l string) bool {
for _, m := range strptimeDirectiveRe.FindAllString(l, -1) {
d := strings.TrimLeft(m, "%-_0^#")
if !okDirectives[strings.TrimPrefix(d, "%")] { return false }
}
return true
} Type guard
func isStrptimeLayoutValid(layout, layoutType string) bool { return layoutType != "strptime" || validStrptime(layout) } Try / catch
On error, prompt the user to re-enter the layout; validate with time.Parse against a sample timestamp before submit.
Prevention
- 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
When it happens
Trigger: {"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.
Common situations: 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.
Related errors
- couldn't generate nil check for field to be removed by op %s
- couldn't generate nil check for parseFrom of time parser op
- couldn't extract log fields referenced in expr %s: %w
- could not create nil check for %s: %w
- could not parse expr: %w
AI-assisted analysis of SigNoz/signoz@5069bf80b0 (2026-08-28).
Data as JSON: /api/errors/2731f33b735f282e.
Report an issue: GitHub.